Building Custom MQL5 Indicators with Buffers and Calculation Modes
Summary
This programming guide explains the structure of custom indicators in MetaTrader 5 and how it differs from earlier MQL4 practice. It walks through indicator properties and inputs, buffer setup, plot configuration, initialization, calculation, and cleanup. A colored RSI example shows how to obtain data through an indicator handle, copy buffer values, and assign color indices according to whether the indicator is rising or falling.
The article also describes two calculation interfaces: one receives chart price and time arrays, while the other accepts a user-selected data array so indicators can be chained or applied to another indicator’s output. It discusses handles, begin and previous-calculation counts, and delayed data availability; BarsCalculated is presented as a way to check readiness before retrying a buffer copy. The material is a platform-specific implementation reference rather than a trading strategy, and its code examples reflect the MQL5 API and terminal behavior at the time of writing.
Key ideas
- Custom MQL5 indicators use initialization, calculation, and optional deinitialization functions.
- Indicator buffers and plot properties control stored values, display behavior, and color indices.
- OnCalculate supports either chart arrays or user-selected input data for chained processing.
- Indicator handles and CopyBuffer provide access to built-in indicator values.
- BarsCalculated can help handle cases where requested indicator data are not ready yet.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.