- MT5 Strategy Tester, possible to switch between multiple timeframes ?
- Multiple candle sizes in EA.
- Current chart timeframe
Hello, is it possible to access OHLC values of multiple timeframes in my code. For example I want to access the former 30 min close, while analyzing the current 5 min candle, something like that.
study this code, previous day close value is being accessed from timeseries

- www.mql5.com
Hello, is it possible to access OHLC values of multiple timeframes in my code. For example I want to access the former 30 min close, while analyzing the current 5 min candle, something like that.
something like this:
datetime time=iTime(_Symbol,PERIOD_CURRENT,index); // access datetime value of index in current chart int H4_index = iBarShift(_Symbol,PERIOD_H4,time,false); // get equivalent index in H4 time frame return iClose(_Symbol,PERIOD_H4, H4_index ); // get Close price related to H4
Remember, you have to deal with 4066 / synchronization issue.
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)
Remember, you have to deal with 4066 / synchronization issue.
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use