Hello,
I made this test script and it doesn't work because I don't know how to multily timeframes correctly.
Print works fine, the result is 240 but the opened chart is always PERIOD_H1.
There is always a warning from the compiler: implicit enum conversion.
How can I correct that?
I just found something to avoid the implicit enum conversion but the opened chart is still the PERIOD_H1 timeframe:
void OnStart() { ENUM_TIMEFRAMES tf=PERIOD_M5; ENUM_TIMEFRAMES htf=(ENUM_TIMEFRAMES)(tf*48); Print(htf); ChartOpen(_Symbol,htf); }
You can't multiply ENUM_TIMEFRAMES.
You have to convert them into seconds (the "time currency" of MQ) to use them in a calculation.
PERIOD_H1 to PERIOD_D1 are internally represented as 16384+number_of_hours. (don't ask me why :)). You can find out more by means of a simple:
void OnStart() { Print(Period()); }
Then there is PeriodSeconds() to convert ENUM_TIMEFRAMES into numbers you can use in calculations; but you'll have to write your own function to convert them back.

- www.mql5.com
PERIOD_H1 to PERIOD_D1 are internally represented as 16384+number_of_hours. (don't ask me why :)). You can find out more by means of a simple:
Then there is PeriodSeconds() to convert ENUM_TIMEFRAMES into numbers you can use in calculations; but you'll have to write your own function to convert them back.
Thanks guys! Now I know how to go on.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I made this test script and it doesn't work because I don't know how to multily timeframes correctly.
Print works fine, the result is 240 but the opened chart is always PERIOD_H1.
There is always a warning from the compiler: implicit enum conversion.
How can I correct that?