Setting and Labeling Horizontal Indicator Levels in MQL5
Summary
This example explains how to display horizontal threshold levels in a separate indicator window and customize their color, line style, and width. Compiler properties can define the initial levels and shared styling, while IndicatorSetInteger allows the indicator to set individual level attributes dynamically. The example also lists the supported solid, dashed, dotted, and dash-dot line styles and shows how a level can be labeled for users, such as an overbought threshold.
A key implementation detail is the difference between property numbering and function indexing: properties start their level numbers at one, whereas the function addresses the first level with index zero. Using the wrong index can apply styling to a different level than intended. This is a programming demonstration of chart presentation, not a trading signal or a performance analysis; it provides no evidence that any particular threshold improves trading results.
Key ideas
- Horizontal levels can be shown in a separate indicator window.
- Compiler properties set level values and baseline visual styles.
- IndicatorSetInteger can set styling attributes for an individual level.
- Property numbering starts at one, while function indexes start at zero.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.