Discussing the article: "Beyond the Clock (Part 3): Building an Indicator Window for Alternative Bars in MQL5"

 

Check out the new article: Beyond the Clock (Part 3): Building an Indicator Window for Alternative Bars in MQL5.

AlternativeBarsViewer is a subwindow indicator that renders all ten alternative bar types as color‑coded candles using the same CBarConstructor hierarchy as BarBuilderEA, ensuring identical bars. It supports three data sources (real ticks, synthetic OHLC ticks, or the EA's CSV) and two render modes (TIME and INDEX) toggleable at runtime. Degenerate bars are highlighted and summarized on a compact panel, enabling live calibration without leaving the terminal.

The two previous articles in this series built all ten alternative bar types defined in Chapter 1 of López de Prado's Advances in Financial Machine Learning: standard bars (time, tick, volume, dollar) in Part 1, and runs bars in Part 2. Both articles ended at the same point: bars written to a CSV file and no way to inspect them inside the terminal.

The natural response is to open the CSV in Python and plot it. This works for small histories. At the scale that alternative bars accumulate during live operation — several thousand dollar bars on an active session, tens of thousands of tick bars over a week — both matplotlib and Plotly hit rendering limits. The browser or the figure canvas degrades before the data is fully drawn. Switching platforms during a parameter sweep is slow enough to break the feedback loop. By the time the chart renders, the EA has already produced another batch of bars.

A harder problem is that static plots can miss critical issues entirely. A miscalibrated imbalance threshold can close bars on three ticks during low-volatility periods. Three ticks produce a bar whose open, high, low, and close are nearly identical — a flat candle with no directional information. In a Python chart of a thousand bars, that bar is a small feature somewhere in the middle. In a MetaTrader subwindow, it appears as a gold candle as soon as it closes. This makes the calibration failure visible before it contaminates the downstream feature pipeline. The real value of in-terminal visualization is not convenience; it is that the parameter space becomes legible during live calibration in a way offline analysis cannot match.

This article implements AlternativeBarsViewer, a custom indicator that renders the ten alternative bar types as color-coded candlesticks in a separate subwindow. The implementation reuses the exact CBarConstructor hierarchy that BarBuilderEA uses, so the candles shown in the subwindow are guaranteed to match the EA's and Python's output. It supports three data sources: real ticks (CopyTicksRange), synthetic ticks from chart OHLC, and the EA's exported CSV. It also provides two display layouts that are toggleable at runtime via a button or hotkey.

Author: Patrick Murimi Njoroge