Felipe Augusto Torres Maggico: After re-connection I should read the previous candle at 10:40:00 and not at 10:35:00.
- Only if you received a tick between the re-connection and 10:45 and called your function. Your log implies no.
- You can only call IsNewBar once per tick; do you call it in OnInit also? Is it coded properly?
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 2014.04.04I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
William Roeder:
- Only if you received a tick between the re-connection and 10:45 and called your function. Your log implies no.
- You can only call IsNewBar once per tick; do you call it in OnInit also? Is it coded properly?
1. Agreed.
2. I run it only once per tick and keep the status in a member variable, here's my IsNewBar():
const bool IsNewBar() const { return m_bNewBar; };

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
Hi,
I'm facing a problem when my MT5 looses its connection and reconnects. Here is the code (simplified):
Here is the log:
After re-connection I should read the previous candle at 10:40:00 and not at 10:35:00.
Thank you.