Using global arrays like Open[], Close[], Low[], High[] in custom indicator for MetaTrader 5
Any suggestion how can I use those arrays?
Both for MQL4+ and MQL5, the OnCalculate() event handler for Indicators. offers local arrays for quotes/rates data in the form of arrays. They are however in lowercase (open[], close[], low[], high[] , etc.).
int OnCalculate( const int rates_total, // size of input time series const int prev_calculated, // number of handled bars at the previous call const datetime& time{}, // Time array const double& open[], // Open array const double& high[], // High array const double& low[], // Low array const double& close[], // Close array const long& tick_volume[], // Tick Volume array const long& volume[], // Real Volume array const int& spread[] // Spread array );
- www.mql5.com
#define SERIES(name,type) \ class C##name \ { \ public: \ type operator[](const int i){return i##name(NULL,0,i);} \ }name; SERIES(Open,double) SERIES(Low,double) SERIES(High,double) SERIES(Close,double) SERIES(Time,datetime) SERIES(Volume,long)
Both for MQL4+ and MQL5, the OnCalculate() event handler for Indicators. offers local arrays for quotes/rates data in the form of arrays. They are however in lowercase (open[], close[], low[], high[] , etc.).
these arrays exists only inside OnCalculate() function. I cannot send all of them as function parameter to each one of functions that requires those values.
For example this function requires close and open arrays.
int getCandleColorIndex(int pos) { return (Close[pos] > Open[pos]) ? 1 : (Close[pos] < Open[pos]) ? -1 : 0; }
Hi,
I'm converting an indicator written for MT4 to use it in MT5.
It has a lot in small functions which uses Open[], Close[], Low[] and High[] global arrays in MQL4. I found that there are no equivalent of them in MQL5.
Any suggestion how can I use those arrays?
Hadi