Difference between Script and EA

 

Hi all,

Can someone explain me why the same peace of code executed in OnStart() of a script and OnTick() of an EA does not give the same result. And what should I do to retrieve indicator value in the EA?

Peace of code :

   int handle=iCustom(_Symbol,_Period,"TrendMagic_V2",50,5);

   double TM_Price[];

   ArraySetAsSeries(TM_Price,true);

   CopyBuffer(handle,0,D'2010.10.01 00:00:00',D'2010.10.01 04:00:00',TM_Price);

   for (int i=0;i<ArraySize(TM_Price)-1;i++)

     Print(" i = ", IntegerToString(i)," TM_Price = ", DoubleToString(TM_Price[i],Digits()));

 

 

     

Files:
 
This is odd, for some reason using a copy buffer for this indicator doesn't seem to work like for other indicators.
Reason: