Download MetaTrader 5

iMAOnArray converting volume trouble?

To add comments, please log in or register
Stephen Reynolds
Stephen Reynolds  

In the following code why does it return my object AVGVol1 as 0.0 and not the average of volume it should?

I see AVGVol[0] works and returns the volume okay, so this array work as far as I see‌. But it doesn't work within the iMAOnArray parameter? Why not? Any help on this I would be much appreciated.

void OnTick()
   double AVGVol[1];
   AVGVol[0] = (double)iVolume(_Symbol,_Period,1);      
   //double avgvol = (double)Volume[0];
   double AVGVol1 = iMAOnArray(AVGVol,1,5,1,MODE_SMA,1);
   double AVGVol2 = iMAOnArray(AVGVol,1,5,1,MODE_SMA,2);
   bool risingvol = (AVGVol1 > AVGVol2);


  1. Why did you posted in the Root / MT5 General section instead of the MQL4 section?
  2. How do you compute a five (5) period moving average with only one value?
  3. And how do you expect to look at the last two values with only one value.
To add comments, please log in or register