Download MetaTrader 5

Using PRICE constants

To add comments, please log in or register
comonsig
8
comonsig  

Hi, I reently migrated from MQL4 and right now I can't find the right sintax for retrieving specific prices.


I wrote the code below, which produces the error message: 'PRICE_HIGH function not defined' (the same for all the other ones).

I was expecting PRICE_HIGH to be equivalent to iHigh from MQL4, but it seams that it's only a constant, and I have no idea how it should be used.


Any help would be appreciated, thanks!


//

void STORE_function20()

{
CAN4h_max = PRICE_HIGH(_Symbol,240,1);
CAN4h_min = PRICE_LOW(_Symbol,240,1);
CAN4h_close = PRICE_CLOSE(_Symbol,240,1);
CAN4h_open = PRICE_OPEN(_Symbol,240,1);
}

Alain Verleyen
Moderator
32828
Alain Verleyen  
Documentation on MQL5: Moving from MQL4
Documentation on MQL5: Moving from MQL4
  • www.mql5.com
Moving from MQL4 - Reference on algorithmic/automated trading language for MetaTrader 5
nicholishen
765
nicholishen  
comonsig:

Hi, I reently migrated from MQL4 and right now I can't find the right sintax for retrieving specific prices.


I wrote the code below, which produces the error message: 'PRICE_HIGH function not defined' (the same for all the other ones).

I was expecting PRICE_HIGH to be equivalent to iHigh from MQL4, but it seams that it's only a constant, and I have no idea how it should be used.


Any help would be appreciated, thanks!


//

void STORE_function20()

{
CAN4h_max = PRICE_HIGH(_Symbol,240,1);
CAN4h_min = PRICE_LOW(_Symbol,240,1);
CAN4h_close = PRICE_CLOSE(_Symbol,240,1);
CAN4h_open = PRICE_OPEN(_Symbol,240,1);
}


MqlRates r[];
ArraySetAsSeries(r,true);
int total = CopyRates(Symbol(),PERIOD_H4,0,Bars(Symbol(),PERIOD_H4),r);

double   O = r[index].open,
         H = r[index].high,
         L = r[index].low,
         C = r[index].close;
To add comments, please log in or register