# How to convert the Open[x] High[x] Low[x] Close[x] from MQL4 to MQL5?

these variables are not available on mql5

what function can i construct to better emulate these Open[0] High[0] Low[0] Close[0] ?

PS - probably best not to double post, people donâ€™t like it

to simplify the conversion i did these functionsâ€¦ im not experienced enough to see if these are the best commands for indicators could you tell about ?

`````` -----------------------------

-----------------------------

-----------------------------

double _open(int index)

{

if(index < 0) return(-1);

double Arr[];

if(CopyOpen(_Symbol,_Period, index, 1, Arr)>0) return(Arr[0]);

else return(-1);

}

double _low(int index)

{

if(index < 0) return(-1);

double Arr[];

if(CopyLow(_Symbol,_Period, index, 1, Arr)>0) return(Arr[0]);

else return(-1);

}

double _high(int index)

{

if(index < 0) return(-1);

double Arr[];

if(CopyHigh(_Symbol,_Period, index, 1, Arr)>0) return(Arr[0]);

else return(-1);

}

double _close(int index)

{

if(index < 0) return(-1);

double Arr[];

if(CopyClose(_Symbol,_Period, index, 1, Arr)>0) return(Arr[0]);

else return(-1);

}

datetime _time(int index)

{

if(index < 0) return(-1);

datetime Arr[];

if(CopyTime(_Symbol,_Period, index, 1, Arr)>0) return(Arr[0]);

else return(-1);

}

int _bars(){

return Bars(_Symbol,_Period);

//int teste = Bars(_Symbol,_Period);

}

double _bid(){

return SymbolInfoDouble(_Symbol,SYMBOL_BID);
``````
``````#define DEFINE_TIMESERIE(NAME, T)                \
class CLASS##NAME                              \
{                                              \
public:                                        \
T operator[]( const int iPos ) const         \
{                                            \
return(::i##NAME(_Symbol, _Period, iPos)); \
}                                            \
};                                             \
\
CLASS##NAME NAME;

DEFINE_TIMESERIE(Volume, long)
DEFINE_TIMESERIE(Time, datetime)
DEFINE_TIMESERIE(Open, double)
DEFINE_TIMESERIE(High, double)
DEFINE_TIMESERIE(Low, double)
DEFINE_TIMESERIE(Close, double)
#undef DEFINE_TIMESERIE``````
1 Like