Demo_IndicatorSetString - MetaTrader 5 Script - MT4/MT5 Resources

An example of how to use indicatorSetString() . A simple indicator showing how to create labels such as "Overbought Level" for each level.
Using the #property compiler directive for indicators drawn in a separate window you can specify the desired horizontal level, for example:
//--- display three horizontal levels in separate indicator windows #Property Indicator Level 1 30 #Property Indicator Level 2 50 #Property Indicator Level 3 70
Additionally, the metricSetString() function can be used to add labels to each level and even change the labels dynamically if necessary:
//--- Set the horizontal level description indicator set string ( INDICATOR_LEVETEXT , 0 , "First level (index 0)" ); Indicator set string ( INDICATOR_LEVETEXT , 1 , "Level 2 (index 1)" ); Indicator set string ( INDICATOR_LEVETEXT , 2 , "Third level (index 2)" );
notes
When using the #property directive, properties (modifiers) are numbered starting from 1 (one), and functions are numbered from 0 (zero). If the level numbers are set incorrectly, the resulting metrics may be different than expected.
For example, to set the description of the first horizontal level, use zero indexing:
Indicator set string ( INDICATOR_LEVETEXT , 0 , "first level" ) //- Index 0 is used to set the first level text description.

Attachment download
📎 demo_indicatorsetstring.mq5 (2.38 KB)
Source: MQL5 #1760
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •