
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
Both of those assumptions may be false. See The Implementation of a Multi-currency Mode in MetaTrader 5 - MQL5 Articles
I don't see anything in that article which unequivocally answers the fundamental question: "If TimeCurrent() updates, can there be any ticks dated earlier than TimeCurrent() which have not yet been processed into the bar history?"
As I said at the top of page 1, I'm not guaranteeing that this is a safe assumption. But it probably is. I think I'll check it on Monday when the markets re-open.
[...] assumption [...]
Returning to the original approach, a lesser optimisation is of course available provided that (a) the array of timeframes is in ascending order, and (b) we're not on MT5 which can potentially have timeframes which aren't multiples of each other. This will typically reduce the number of loop iterations from 140 to 28:
Strictly speaking, this also contains something of an assumption about the way that MT4 works internally: that updates of candles are tick-driven, and that the candle history for all timeframes is consistently updated before making it available to EAs and indicators. But that's an assumption so widely used and for so long that it must be correct.
As I said at the top of page 1, I'm not guaranteeing that this is a safe assumption. But it probably is. I think I'll check it on Monday when the markets re-open.
It's impossible to disprove a negative, but everything which I'm seeing suggests that this is a safe assumption: if TimeCurrent() updates to a new minute, then all candle data on all markets for the previous minute will be final, and won't update further. (Obvious special exception for when MT4 is starting up, and receiving a combination of live data and old data to fill gaps in charts.)
Without intending to, I've even checked this on a terrible internet connection with slow speeds and lots of packet-loss. Remains the case that candle data which is grabbed when TimeCurrent() updates is consistent with a later check that those candles didn't receive further updates.