Function to get the candle date

 

I would like to know whether there is any function that I can use to get the candle date.

Ex: if I have 30 daily candle, I want to print the candle date for each of those candles. Is there a function for this in mql?

 
don per: I would like to know whether there is any function that I can use to get the candle date. Ex: if I have 30 daily candle, I want to print the candle date for each of those candles. Is there a function for this in mql?
Yes there is but it depends on the environment and so will affect our suggestion for which one(s) will be more suitable for what you plan to do:
  • MQL4 or MQL5?
  • Indicator, Expert Advisor or Script?
 

MQL4

Expert Advisor

 
don per:

MQL4

Expert Advisor

You can use the Time[] series array, or the the iTime() function.

You can also use the CopyTime(), CopyRates(), or ArrayCopyRates() or ArrayCopySeries() but these are less well known and more complex in MQL4.

iTime - Timeseries and Indicators Access - MQL4 Reference
iTime - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
Time value for the bar of specified symbol with timeframe and shift. If local history is empty (not loaded), function returns 0. To check errors, one has to call the GetLastError() function.
 
Thanks a lot for your replies. Will try them out.
Reason: