We implement a multi‑timeframe aggregator that prevents mixing bars from different moments. It validates grid alignment, recency to the forming base bar, and closed‑bar end times, and returns either a complete bundle or a structured error. A re‑read guards against races with a new base bar, while a fake bar source powers fifteen reproducible tests and a demo indicator that plots on valid data only.
A strategy reads the last closed M15, H1, and H4 bars with three separate calls. Between the second and the third call, the H4 series rolls to a new bar. The strategy now pairs an M15 bar that ended at 11:45 with an H4 bar that ends at 12:00, fifteen minutes later. Nothing in the code complains, and the result looks plausible.
This article presents a small MQL5 library that makes that mistake visible. The CMultiTFAggregator class reads one closed bar per requested timeframe and checks every open time against four rules. It returns either an aligned bundle or a structured error, and it never returns partial data as valid.
You will learn how to derive alignment rules from bar open times and why raw bar counts cannot serve as the test. You will also see how a bounded re-read detects a base bar that changed during the read. An abstract bar source lets you test the logic with synthetic series, without a terminal.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check out the new article: Multi-Timeframe Bar Aggregator with Conflict Detection in MQL5.
A strategy reads the last closed M15, H1, and H4 bars with three separate calls. Between the second and the third call, the H4 series rolls to a new bar. The strategy now pairs an M15 bar that ended at 11:45 with an H4 bar that ends at 12:00, fifteen minutes later. Nothing in the code complains, and the result looks plausible.
This article presents a small MQL5 library that makes that mistake visible. The CMultiTFAggregator class reads one closed bar per requested timeframe and checks every open time against four rules. It returns either an aligned bundle or a structured error, and it never returns partial data as valid.
You will learn how to derive alignment rules from bar open times and why raw bar counts cannot serve as the test. You will also see how a bounded re-read detects a base bar that changed during the read. An abstract bar source lets you test the logic with synthetic series, without a terminal.
Author: Ushana Kevin Iorkumbul