Download MetaTrader 5

How to find Time frame of current chart

To add comments, please log in or register
elektor
34
elektor 2011.04.28 11:17 

Hi,

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

 Regards 

Andriy Moraru
1261
Andriy Moraru 2011.04.28 11:35  
No, but there are only 21 different timeframes, so you could write your own function that would return string values.
elektor
34
elektor 2011.04.28 17:07  
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 

Amir Yacoby
1195
Amir Yacoby 2011.04.28 19:07  
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
elektor
34
elektor 2011.04.29 10:09  

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?

Andriy Moraru
1261
Andriy Moraru 2011.04.29 13:29  
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");

To add comments, please log in or register