how to compare zigzag with MA in EA

 

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

 
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 . .
 

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

 
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
Reason: