Something with iMAOnArray

 
Hi all,

I'm on a verge of bilding multi pairs EA and I found some problem.

I've try to trace the problem and checking some codes but I'm, stuck on this.

Is anybody know why ma1 and ma2 are resulting different?


   int MAPeriod=100;
   int MAMethod=0;

   double clos[500];
   for(int k=0;k<500;k++)
   {
      clos[k]=Close[k];
   }
   
   double ma1=iMAOnArray(clos,0,MAPeriod,0,MAMethod,1);
   double ma2=iMA(Symbol(),0,MAPeriod,0,MAMethod,PRICE_CLOSE,1);


Thanks for your help

 
devilian1899:
Hi all,

I'm on a verge of bilding multi pairs EA and I found some problem.

I've try to trace the problem and checking some codes but I'm, stuck on this.

Is anybody know why ma1 and ma2 are resulting different?



Thanks for your help



   int MAPeriod=100;
   int MAMethod=0;

   double clos[500];
   ArraySetAsSeries(clos,true);

   for(int k=0;k<500;k++)
   {
      clos[k]=Close[k];
   }
   
   double ma1=iMAOnArray(clos,0,MAPeriod,0,MAMethod,1);
   double ma2=iMA(Symbol(),0,MAPeriod,0,MAMethod,PRICE_CLOSE,1);
 
Without the array being AsSeries, you are asking for the MA(1) so the MAoa only has clos[0] and clos[1] to work with.
 
Oh thank you.. forgot to add that part.
honest_knave:


I see, thanks.

WHRoeder:
Without the array being AsSeries, you are asking for the MA(1) so the MAoa only has clos[0] and clos[1] to work with.
Reason: