Download MetaTrader 5

how to compare zigzag with MA in EA

To add comments, please log in or register
Added support for the Spanish language. Come and check it out!
Jhonson
35
Jhonson 2013.11.29 15:36 

zigzag = iCustom("EURUSDpro",PERIOD_M15,"ZigZag",12,5,3,0,0)

MA = iMA("EURUSDpro",PERIOD_M15,7,0,MODE_EMA,PRICE_CLOSE,0)

zigzag

help me. how to zigzag with MA

If zigzag < MA ==> buy

If zigzag >MA ==> sell

thanks

Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2013.11.29 16:07  
axbc:

zigzag = iCustom("EURUSDpro",PERIOD_M15,"ZigZag",12,5,3,0,0)

MA = iMA("EURUSDpro",PERIOD_M15,7,0,MODE_EMA,PRICE_CLOSE,0)


help me. how to zigzag with MA

If zigzag < MA ==> buy

If zigzag >MA ==> sell

thanks

You have to go back through the bars to find the ZigZag points, the Indicator buffer will have a value when there is a ZigZag. When you find it yo can compare it against the MA value you want to use . .
Jhonson
35
Jhonson 2013.11.29 16:27  

thank you

I write code

double zigzag;
      int k=0;
      int i=0;
      while(k<4){
         if(iCustom("GBPUSBpro",PERIOD_M15,"ZigZag",12,5,3,0,i)!=0){
            zigzag[k]=iCustom("GBPUSBpro",PERIOD_M15,"ZigZag",12,5,3,0,i);
            k++;
         }
         i++;
      }


if ( zigzag  <  iMA("GBPUSBpro",PERIOD_M15,7,0,MODE_EMA,PRICE_CLOSE,0) ) ) 
   {  BUY("GBPUSBpro",B_GBPUSBpro_LS_0,B_GBPUSBpro_TP_0,B_GBPUSBpro_SL_0,B_GBPUSBpro_TS_0,"if (  ( zigzag  < iMA(GBPUSBpro,PERIOD_M15,21,0,MODE_EM...") ;}

but it do not run

can u help me

Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2013.11.29 17:12  
axbc:

thank you

I write code

but it do not run

can u help me

Don't check if the value returned by iCustom() is not equal to 0 check if it is less than EMPTY_VALUE
To add comments, please log in or register