Download MetaTrader 5

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

To add comments, please log in or register
jon
465
jon  
How to get the OHLC (Open, High, Low, Close) of the last 1 min bar?
Alain Verleyen
Moderator
31203
Alain Verleyen  
jon:
How to get the OHLC (Open, High, Low, Close) of the last 1 min bar?
mql5 or mql4 ?
whroeder1
14785
whroeder1  
Predefined Variables - MQL4 Reference
Predefined Variables - MQL4 Reference
  • docs.mql4.com
Predefined Variables - MQL4 Reference
Osama Shaban
1470
Osama Shaban  
double  open = iOpen(Symbol(),1,1);
double close = iClose(Symbol(),1,1);
double  high = iHigh(Symbol(),1,1);
double   low = iLow(Symbol(),1,1);
whroeder1
14785
whroeder1  
Osama Shaban:
The OP hasn't yet stated MT4 or MT5 and posted in the MT5 forum. Those functions do not exist in MT5.
jon
465
jon  
whroeder1:
The OP hasn't yet stated MT4 or MT5 and posted in the MT5 forum. Those functions do not exist in MT5.
MQL5
Alain Verleyen
Moderator
31203
Alain Verleyen  
jon:

MQL5

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 */

To add comments, please log in or register