TDI Red Green EA

 

Hi Guys,

I'm currently working on an EA.

I got an TDI Red Green Indicator. Every time there's a cross of both lines, there shall be ONE trade.

So if the red line crosses above the green line, there shall be Short trade and every time the red line crosses below the green line there shall be a long trade.

unfortunately it doesn't work, how it suppose to.

Anyones able to spot out the mistakes?


TIA,

Wez


/+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
      
bool Fact_Up = true;             // status to guarantee only..    
bool Fact_Dn = true;             // one signal per cross     
int ticket;
   

int start()                           
  {
   //double MA;                         
   double TDIred;
   double TDIgreen;
   double Spread = Ask-Bid;
   int Slippage = Spread/Point;                                      
     
   TDIred = iCustom(Symbol(),PERIOD_M1, "TDI Red Green",13,5,0); 
   TDIgreen = iCustom(Symbol(),PERIOD_M1, "TDI Red Green",13,3,0);

   if (TDIgreen > TDIred && Fact_Up == true)   // check if green line is above
     {
      ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
     if(ticket<0)
       {
        Print("OrderSend failed with error #",GetLastError());
        return(0);
       }

      //OrderSend(Symbol(),OP_BUY,0.01,Ask,Slippage,40,10,TimeToStr(Time[0]),8888,0,Blue);
      Fact_Dn = true;                //Change status, so they won't be further trades on this cross
      Fact_Up = false;                 
      Alert("Green TDI is above red TDI - Buy Phase");
      Comment("Buy Phase"); 
     }

   if (TDIgreen < TDIred && Fact_Dn == true)   
     {
     ticket=OrderSend(Symbol(),OP_SELL,1,Ask,3,Ask+25*Point,Ask-25*Point,"My order #2",16384,0,Green);
     if(ticket<0)
       {
        Print("OrderSend failed with error #",GetLastError());
        return(0);
       }
      //OrderSend(Symbol(),OP_SELL,0.01,Ask,Slippage,40,10,TimeToStr(Time[0]),8888,0,Red);
      Fact_Up = true;                 //Change status, so they won't be further trades on this cross
      Fact_Dn = false;                 
      Alert("Green TDI is below red TDI - Sell Phase.");
      Comment("Sell Phase");
     }
  
   
   return;                            
  }
 
wezl3y:


Hi Guys,

Anyones able to spot out the mistakes?

What have you tested ? what exactly doesn't work ? placing order, just placing one at a time ? can we see the Indicators ?

 

Found the Indicator . . . it has these Externs

extern int RSI_Period = 13;         //8-25
extern int RSI_Price = 0;           //0-6
extern int Volatility_Band = 34;    //20-40
extern int RSI_Price_Line = 2;      
extern int RSI_Price_Type = 0;      //0-3
extern int Trade_Signal_Line = 7;   
extern int Trade_Signal_Type = 0;   //0-3

when you use iCustom you have to pass all the Externs . .

https://docs.mql4.com/indicators/iCustom

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.
 
RaptorUK:

Found the Indicator . . . it has these Externs

when you use iCustom you have to pass all the Externs . .

https://docs.mql4.com/indicators/iCustom

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.


>>you have to pass all the Externs . .

Are you shure? i have the sensation, if i dont pass something of the parameters its calling the iCustom with the default settings of the indicator...

 
EADeveloper:


>>you have to pass all the Externs . .

Are you shure?

Nope, not sure . . . try it and see if it works . . .
 
RaptorUK:
Nope, not sure . . . try it an d see if it works . . .

Thanks for quick replies.


I've just tried to give all parameters by the iCustom call, but it doesn't change the problem. I ran it in the strategy tester and it doesn't do any trade. It just gives me the "#130 Order failed" in the journal.

What also figured out, is that it doesn't show the 'buy phase' comment even if the green line is above the red line... This might be a sign for the mistake.

 
TDIred = iCustom(Symbol(),PERIOD_M1, "TDI Red Green",13,5,0); 
TDIgreen = iCustom(Symbol(),PERIOD_M1, "TDI Red Green",13,3,0)
  1. You have to pass ALL externs as others pointed out.
  2. You have to select which buffer (mode) before the shift (0)
  3. 130 is a separate problem. EAs must adjust for 4/5 digit brokers. 25*point is 2.5 pips on a 5 digit broker less than MarketInfo(Symbol(), MODE_STOPLEVEL)*Point (30 points 3.0 pips on IBFX) On ECN brokers you must open first and THEN set stops.
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

 
wezl3y:

What also figured out, is that it doesn't show the 'buy phase' comment even if the green line is above the red line... This might be a sign for the mistake.

Are you on a 5 digit broker ? if you are your SL is only 2.5 pips and may be too close . . also your sell order should be at Bid move your SL and TP further away and test . . .

Error 130:

ERR_INVALID_STOPS, 130, Stops are too close, or prices are ill-calculated or unnormalized (or in the open price of a pending order). The attempt can be repeated only if the error occurred due to the price obsolescense. After 5-second (or more) delay, it is necessary to refresh data using the RefreshRates function and make a retry. If the error does not disappear, all attempts to trade must be stopped, the program logic must be changed.

 
RaptorUK:

Are you on a 5 digit broker ? if you are your SL is only 2.5 pips and may be too close . . also your sell order should be at Bid move your SL and TP further away and test . . .

Error 130:

ERR_INVALID_STOPS, 130, Stops are too close, or prices are ill-calculated or unnormalized (or in the open price of a pending order). The attempt can be repeated only if the error occurred due to the price obsolescense. After 5-second (or more) delay, it is necessary to refresh data using the RefreshRates function and make a retry. If the error does not disappear, all attempts to trade must be stopped, the program logic must be changed.


WHRoeder:
  1. You have to pass ALL externs as others pointed out.
  2. You have to select which buffer (mode) before the shift (0)
  3. 130 is a separate problem. EAs must adjust for 4/5 digit brokers. 25*point is 2.5 pips on a 5 digit broker less than MarketInfo(Symbol(), MODE_STOPLEVEL)*Point (30 points 3.0 pips on IBFX) On ECN brokers you must open first and THEN set stops.


Thanks to y'all. Now it's working. Thank you sooo much!!!

 

Hi

 

I wonder if you could share the completed TDI EA bro.

 

Thanks 

 
Edward Moniaga Mo:

Hi

 

I wonder if you could share the completed TDI EA bro.

 

Thanks 

It has been over 5 years since they posted... Good luck!


Reason: