Recently, I developed an indicator that successfully reads all the indicators present on a chart. To achieve this, I store the indicators found in a collection variable and then utilize a for loop to print their current values. The indicator works flawlessly for indicators that use the primary bars series. However, it encounters problems when an indicator input series relies on another Bars series, resulting in the script either failing or returning a value of 0 as the current value.
Since the indicators are added by the user and not my script, I am unsure how to determine if an indicator is based on the primary bars or some secondary bars series. I am using the following line to read the current value:
// process item 'i' in the collection of indicators _indicator = indicatorCollection[i]; // find bar index last bar int _lastBar = (ChartBars.Count-1) - (_indicator.Calculate == Calculate.OnBarClose ? 1:0); // get current value of 1st plot double _curPlotVal = _indicator.Values[0].GetValueAt(_lastBar);
I would greatly appreciate any insights or guidance you can provide to help me resolve this issue and make my indicator compatible with indicators based on secondary bars series.
Thank you for your attention and support.

Comment