Open[], High[], .. Volume[] equivalent in MQL5

 

Hi,

is there an equivalent for Open[], High[], .. Volume[] of MQL4 in MQL5?

Actually I am using Volume[i] in OnInit for a volume-indicator in a separate chart-window to set the max. and min.

int OnInit() {
   ...
   while(b-->0) {
      lMin = fmin(lMin,Volume[b]);
      lMax = fmax(lMax,Volume[b]);
   }
   IndicatorSetDouble(INDICATOR_MINIMUM,lMin*0.9);
   IndicatorSetDouble(INDICATOR_MAXIMUM,lMax*1.0);
   ...
}
But Volume[] isn't supported in MQL5 - do I have to use iVolume(_Symbol, ...) or is there a (faster) similar 'direct' way?
 
long volume_=volu(1);


////////////////////////////////////////////////////////////////
long volu(int CC)
{
long volumes[];
CopyTickVolume(Symbol(),0,CC,1,volumes);

return(volumes[0]);
}
 
Carl Schreiber:

Hi,

is there an equivalent for Open[], High[], .. Volume[] of MQL4 in MQL5?

...

Forum on trading, automated trading systems and testing trading strategies

How to get the OHLC of the last 1 min bar?

Alain Verleyen, 2016.11.09 23:04

With CopyXXX() functions. CopyRates() will give you OHLC.


   MqlRates rates[1];
   if(CopyRates(Symbol(),PERIOD_M1,0,1,rates)!=1) { /*error processing */ };

   /* USAGE: rates[0].open ; rates[0].high ; rates[0].low ; rates[0].close */

And also rates[0].tick_volume
 

So this means there are no array of values which I directly can access like Volume[i].

I have to have a dynamic array which will be resized and I have to loop though this dynamic array - correct?

 
Carl Schreiber:

So this means there are no array of values which I directly can access like Volume[i].

I have to have a dynamic array which will be resized and I have to loop though this dynamic array - correct?

Yes and no.

It doesn't have to be a dynamic array, but yes there no "direct access" like in mql4.

You don't have to loop to find a minimum, maximum, you can use ArrayMinimum(), ArrayMaximum() functions. (By the way these functions exist also in mql4).

 
Alain Verleyen:

Yes and no.

It doesn't have to be a dynamic array, but yes there no "direct access" like in mql4.

You don't have to loop to find a minimum, maximum, you can use ArrayMinimum(), ArrayMaximum() functions. (By the way these functions exist also in mql4).

ok - but either me in one loop or ArrayMinimum() and ArrayMaximum() in two separate loops have to do that.
 
 
Thanks to all of you - even though it is not totally what I was looking for.
 
Carl Schreiber:
Thanks to all of you - even though it is not totally what I was looking for.
You asked for equivalent of Open[], .. Volume[]. All you need is include the library. Then Volume[] will be defined, and your code should compile and run as expected.
 
You are right, but I try to use functions variables, ... that are supported by mql5 as well - and Open[], High[],.. Volume[] aren't.
 
Carl Schreiber:
ok - but either me in one loop or ArrayMinimum() and ArrayMaximum() in two separate loops have to do that.
So what is the problem ? I don't get it.
Reason: