.
.
I am confused, I can not draw a conclusion.
MTF coding is simple and easy on MT4, but its getting annoying on MT5.
If you want to MTF indicators on MT5 to work on weekends, you should do some extra job such as call Oncalculate() in OnTimer()...
Just share the info. in the forum.
Yes, it seems that MT5 has some stupid behaviour. I'm also struggling with the "weekend" problem.
I found that this code is problematic:
int maxBars=iBars(Symbol(),PERIOD_CURRENT);
It gives 0 to me when I'm switching between time frames.
When I'm switching between M1/M5/M15/M30/H1 it works well, but above H1 it doesnt work and gives 0 (although there are bars on the chart, the indicator cannot "see" them).
I have no idea. Extremely annoying.
I tried this example to update the bars and get the proper value, but no success.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4
The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero the first call.
On MT5: Unless the chart is that specific pair/ TF, you must Synchronize the terminal Data from the Server.
Is it mystical?! It is! -
Withdraw - Technical Indicators - MQL5 programming forum
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
I am confused, I can not draw a conclusion.
MTF coding is simple and easy on MT4, but its getting annoying on MT5.
If you want to MTF indicators on MT5 to work on weekends, you should do some extra job such as call Oncalculate() in OnTimer()...
Just share the info. in the forum.
You are right it's confusing.
However there is a simple solution, just refresh you chart (right-click on the chart -> Refresh). This can also be done by code using ChartSetSymbolPeriod(0,NULL,0), it will refresh all indicators on all charts using the given symbol. This will work well in most cases, only if you have more complex indicators it could become really difficult to solve.
There are other solutions using timer or chartevent, but they have their own drawbacks.
You are right it's confusing.
However there is a simple solution, just refresh you chart (right-click on the chart -> Refresh). This can also be done by code using ChartSetSymbol(0,NULL,0), it will refresh all indicators on all charts using the given symbol. This will work well in most cases, only if you have more complex indicators it could become really difficult to solve.
There are other solutions using timer or chartevent, but they have their own drawbacks.
Just a small (typo) correction : it is ChartSetSymbolPeriod(0,NULL,0) not ChartSetSymbol(0,NULL,0)
PS: when the time frame data is loaded for the first time since the terminal started (the target time frame or the chart time frame), that will not work either

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
test_event_trigger.mq5 --- this is an empty indicator which is used to generate "tick event" when it is loaded to a chart.
Note:
If your MT5 has not enough local data ,you should disconnect the MT5 server to avoid the chart update which will call OnCalculate().
If you do testing is not at the weekend, you should disconnect the MT5 server.
MA-MTF.mq5
test_event_trigger.mq5
//