protected override void Initialize() { Add(new Plot(Color.Transparent, "Hull_MA_Short")); Add(new Plot(Color.Transparent, "Hull_MA_Long")); Add(new Plot(Color.Black, PlotStyle.Bar,"HMA_Diff")); DrawOnPricePanel = false; Overlay = true; // Plots the indicator on top of price diffSeries1 = new DataSeries(this); diffSeries2 = new DataSeries(this); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { double value1 = 2 * WMA(Inputs[0], (int)(Period_S / 2))[0]; double value2 = WMA(Inputs[0], Period_S)[0]; diffSeries1.Set(value1 - value2); Value_S.Set(WMA(diffSeries1, (int) Math.Sqrt(Period_S))[0]); double value3 = 2 * WMA(Inputs[0], (int)(Period_L / 2))[0]; double value4 = WMA(Inputs[0], Period_L)[0]; diffSeries2.Set(value3 - value4); Value_L.Set(WMA(diffSeries2, (int) Math.Sqrt(Period_L))[0]); Value_Diff.Set(Value_S[0] - Value_L[0]); double value5 = Value_Diff[0]; if (value5 > 0) { BackColor = Color.PaleGreen; } else BackColor = Color.LightSalmon; }
Thanks
DaveN
Comment