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

 
How to get the OHLC (Open, High, Low, Close) of the last 1 min bar?
 
jon:
How to get the OHLC (Open, High, Low, Close) of the last 1 min bar?
mql5 or mql4 ?
 
Predefined Variables - MQL4 Reference
Predefined Variables - MQL4 Reference
  • docs.mql4.com
Predefined Variables - MQL4 Reference
 
double  open = iOpen(Symbol(),1,1);
double close = iClose(Symbol(),1,1);
double  high = iHigh(Symbol(),1,1);
double   low = iLow(Symbol(),1,1);
 
Osama Shaban:
The OP hasn't yet stated MT4 or MT5 and posted in the MT5 forum. Those functions do not exist in MT5.
 
whroeder1:
The OP hasn't yet stated MT4 or MT5 and posted in the MT5 forum. Those functions do not exist in MT5.
MQL5
 
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 */

 
Alain Verleyen #:
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 */

Is there a way of getting the OHLC data of the last 10 candles as an array that can be written to a .txt file?

 
Caspase #: Is there a way of getting the OHLC data of the last 10 candles as an array that can be written to a .txt file?

You have quoted the answer. Use CopyRates to get the data, and write it to a file — Documentation on MQL5: File Functions

Documentation on MQL5: File Functions
Documentation on MQL5: File Functions
  • www.mql5.com
File Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5