Mapping Color Buffers for Multi-Symbol, Multi-Timeframe Indicators in MQL5
Summary
This article explains how MQL5 represents colored indicator plots when an indicator handles multiple symbols and timeframes. A plotted series may need one or more data arrays, depending on its drawing style, plus a separate color-index array for colored plots. The color-index buffer follows the plot’s data buffers, and its values select among the colors configured for that plot. The article illustrates the mapping with line, filling, candle, and histogram styles, then applies the approach to standard indicators and a chart panel that compares indicator states.
Its practical contribution is implementation guidance for assembling plot buffers and retrieving indicator data through CopyBuffer. The examples show how plot styles determine buffer counts and how selected colors can communicate differing indicator states. The article also reports a limitation: CopyBuffer can return an error for non-current symbol or timeframe data even after calculation appears complete; changing the chart timeframe may allow the data to be copied. It is a coding reference, not evidence that colored indicators improve trading performance.
Key ideas
- Colored plots use a data buffer and a separate buffer of color indexes.
- The required number of data arrays depends on the plot’s drawing style.
- The color-index buffer is assigned after the data arrays belonging to its plot.
- Dynamic plot colors can be set through plot properties and changed during execution.
- CopyBuffer may fail to retrieve calculated data for another symbol or timeframe until the chart period is changed.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.