I am trying to understand this problem since past few hours. In the code snippet shown below, I have two classes both derived from Indicator. One of the class refers to another using C# Indexer and I am unable figure out where it links to.
myMacd.cs contains first indicator that adds four plots in its Initialize() method
myMacd.cs gets used in DivergenceSpotter.cs which calls automatically generated method on myMacd and then simply accesses a double value from one of the array using [0] syntax.
My query is: Which of the four plots does the [0] is referred to by statement shown in Bold Red Colored line. It calls a method a defined in Indicator class along with parameters and returns my object. the [] indexer is defined in IndicatorBase class and I am unable to find its documentation. This construct is used in many places including the Divergence Spotter that is attached at beginning of this thread. In the sample code, there are 12 Indicators.
// Filename: myMACD.cs public class myMACD : Indicator { protected override void Initialize() { Add(new Plot(Color.Green, "MACD")); Add(new Plot(Color.DarkViolet, "Signal")); Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Histogram")); Add(new Line(Color.DarkGray, 0, "Median")); } ...... } public partial class Indicator : IndicatorBase { private myMACD[] cachemyMACD = null; private static myMACD checkmyMACD = new myMACD(); public myMACD myMACD(int fast, int slow, int smooth) { return myMACD(Input, fast, slow, smooth); } public myMACD myMACD(Data.IDataSeries input, int fast, int slow, int smooth) { } } ================================= // Filename: myDivergenceSpotter.cs public class myDivergenceSpotter : Indicator { private DataSeries TheIndicator; protected override void Initialize() { TheIndicator = new DataSeries(this); } protected override void OnBarUpdate() { [B][COLOR="Red"]TheIndicator.Set(myMACD(12, 26, 9)[0]);[/COLOR][/B] } }
Comment