If this is not the correct place to ask please let me know. I am trying to add a signal line to the built in TSI indicator. Instead of converting the one from this thread, I made a copy of the built in TSI and then added the bolded changes below to the code. The problem I'm having is that only the TSI line is plotted and not the signal line. (Sorry about the bold messing up the formatting) It worked once where the signal line was displayed but not the TSI. I changed one thing and after compiling it only shows the TSI line now. Not sure why both plots are not showing. Thanks for any help you may be able to provide.
namespace NinjaTrader.NinjaScript.Indicators { /// <summary> /// The TSI (True Strength Index) is a momentum-based indicator, developed by William Blau. /// Designed to determine both trend and overbought/oversold conditions, the TSI is /// applicable to intraday time frames as well as long term trading. /// </summary> public class TSISignal : Indicator { private double constant1; private double constant2; private double constant3; private double constant4; private Series<double> fastEma; private Series<double> fastAbsEma; private Series<double> slowEma; private Series<double> slowAbsEma; [B]private Series<double> signalEma;[/B] protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionTSI; Name = "TSI Signal"; Fast = 9; IsSuspendedWhileInactive = true; Slow = 14; [B]signalEmaLength = 2; [/B] [B]AddPlot(Brushes.Gray, "signalEma");[/B] AddPlot(Brushes.DarkCyan, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameTSI); AddLine(Brushes.White, 1, "ZeroLine"); } else if (State == State.Configure) { constant1 = (2.0 / (1 + Slow)); constant2 = (1 - (2.0 / (1 + Slow))); constant3 = (2.0 / (1 + Fast)); constant4 = (1 - (2.0 / (1 + Fast))); } else if (State == State.DataLoaded) { fastAbsEma = new Series<double>(this); fastEma = new Series<double>(this); slowAbsEma = new Series<double>(this); slowEma = new Series<double>(this); [B]signalEma = new Series<double>(this);[/B] } } protected override void OnBarUpdate() { if (CurrentBar == 0) { fastAbsEma[0] = 0; fastEma[0] = 0; slowAbsEma[0] = 0; slowEma[0] = 0; Value[0] = 0; [B]signalEma[0] = 0;[/B] } else { double momentum = Input[0] - Input[1]; slowEma[0] = momentum * constant1 + constant2 * slowEma[1]; fastEma[0] = slowEma[0] * constant3 + constant4 * fastEma[1]; slowAbsEma[0] = Math.Abs(momentum) * constant1 + constant2 * slowAbsEma[1]; fastAbsEma[0] = slowAbsEma[0] * constant3 + constant4 * fastAbsEma[1]; Value[0] = fastAbsEma[0] == 0 ? 0 : 100 * fastEma[0] / fastAbsEma[0]; [B]signalEma[0] = EMA(Value, signalEmaLength)[0];[/B] } } #region Properties [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof (Custom.Resource), Name = "Fast", GroupName = "NinjaScriptParameters", Order = 0)] public int Fast { get; set; } [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "Slow", GroupName = "NinjaScriptParameters", Order = 1)] public int Slow { get; set; } [B] [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "SignalEMALength", GroupName = "NinjaScriptParameters", Order = 2)] public int signalEmaLength { get; set; }[/B]
Comment