How to find Time frame of current chart

 

Hi,

Is there a function to get the time frame of the current chart in string format?

 Regards 

 
No, but there are only 21 different timeframes, so you could write your own function that would return string values.
 
enivid:
No, but there are only 21 different timeframes, so you could write your own function that would return string values.

But I would need some function which could atleast return a symbolic representation of the time frame so that I can use it to return. Is there a function which can do this?

I see the enumeration ENUM_TIMEFRAMES, is there some way to use this?

Regards 

 
elektor:

But I would need some function which could atleast return a symbolic representation of the time frame so that I can use it to return. Is there a function which can do this?

I see the enumeration ENUM_TIMEFRAMES, is there some way to use this?

Regards 

https://www.mql5.com/en/docs/check/period

Documentation on MQL5: Checkup / Period
  • www.mql5.com
Checkup / Period - Documentation on MQL5
 

Thanks Amir,

I ran the code over the 5minute time frame versus a 1Hour time frame. I correctly got the 5 in the 5 min Time frame but I get 16385 when I run it over the 1 hour timeframe. How is this to be interpreted?

 
elektor:

Thanks Amir,

I ran the code over the 5minute time frame versus a 1Hour time frame. I correctly got the 5 in the 5 min Time frame but I get 16385 when I run it over the 1 hour timeframe. How is this to be interpreted?

Are you trying to Print() it? Try doing it this way:

if (Period() == PERIOD_H1) Print("1 hour");

 

You could check out

int PeriodSeconds(PERIOD_CURRENT) /it returns the timeframe in seconds and you can convert from there/

https://www.mql5.com/en/docs/common/periodseconds

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