peterbabs:
In MQL4, below code works pretty well.
But in MQL5, I'm getting errors when I make the timeframe an int variable.
What's the data type for declaring the timeframe (e.g. PERIOD_H1 ) as a variable/placeholder in MQL5? I can't seem to find it in the documentation.
I need to maintain TF as a variable.
Your advise is appreciated.
In MQL4, below code works pretty well.
But in MQL5, I'm getting errors when I make the timeframe an int variable.
What's the data type for declaring the timeframe (e.g. PERIOD_H1 ) as a variable/placeholder in MQL5? I can't seem to find it in the documentation.
I need to maintain TF as a variable.
Your advise is appreciated.
Use ENUM_TIMEFRAMES enumeration

Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Chart Timeframes
- www.mql5.com
All predefined timeframes of charts have unique identifiers. The PERIOD_CURRENT identifier means the current period of a chart, at which a mql5-program is running.
peterbabs: What's the data type for declaring the timeframe (e.g. PERIOD_H1 )
Perhaps you should read the manual. List of MQL5 Constants → PERIOD_H1 → Chart Timeframes → ENUM_TIMEFRAMES
Thank you all.
I figured it out after posting.
Didn't know previously that ENUM_TIMEFRAMES is actually a data type.

Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Chart Timeframes
- www.mql5.com
All predefined timeframes of charts have unique identifiers. The PERIOD_CURRENT identifier means the current period of a chart, at which a mql5-program is running.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
But in MQL5, I'm getting errors when I make the timeframe an int variable.
What's the data type for declaring the timeframe (e.g. PERIOD_H1 ) as a variable/placeholder in MQL5? I can't seem to find it in the documentation.
I need to maintain TF as a variable.
Your advise is appreciated.