Detect Method of Loading an Indicator Onto a Chart?

 

Hello - I have written an indicator that uses the OnChartEvent event that draws lines onto the chart. When this indicator is loaded by an EA using IndicatorCreate, drawing the indicator on the chart is not required. Although not drawn on the chart, the function for drawing the lines is still run. Can someone suggest a way to detect if the indicator has been added to the chart via IndicatorCreate vs added to the chart in the usual way?

The only way I can think of is by passing an extra setting to the indicator via MqlParams in IndicatorCreate or by communicating between the EA and Indicator using a global variable.

Thank you.

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
There is no distinction between a manually added indicator or one added via code, so your proposed work-around ideas are viable options.