Remove RSI smoothing parameters from ConnorsRSI indicator as they are unnecessary

This commit is contained in:
moshferatu 2025-01-08 12:52:15 -08:00
parent fe1761892b
commit ee958e72f3

View File

@ -13,6 +13,8 @@ namespace NinjaTrader.NinjaScript.Indicators
[CategoryOrder("Lines", 3)] [CategoryOrder("Lines", 3)]
public class ConnorsRSI : Indicator public class ConnorsRSI : Indicator
{ {
private const int RSISmoothing = 1;
private RSI rsi; private RSI rsi;
private RSI streakRsi; private RSI streakRsi;
private ROC roc; private ROC roc;
@ -37,9 +39,7 @@ namespace NinjaTrader.NinjaScript.Indicators
IsSuspendedWhileInactive = true; IsSuspendedWhileInactive = true;
RSIPeriod = 3; RSIPeriod = 3;
RSISmoothing = 1;
StreakRSIPeriod = 2; StreakRSIPeriod = 2;
StreakRSISmoothing = 1;
PercentRankPeriod = 100; PercentRankPeriod = 100;
AddPlot(new Stroke(Brushes.Yellow, 3), PlotStyle.Line, "ConnorsRSI"); AddPlot(new Stroke(Brushes.Yellow, 3), PlotStyle.Line, "ConnorsRSI");
@ -52,7 +52,7 @@ namespace NinjaTrader.NinjaScript.Indicators
rsi = RSI(RSIPeriod, RSISmoothing); rsi = RSI(RSIPeriod, RSISmoothing);
streak = new Series<double>(this, MaximumBarsLookBack.Infinite); streak = new Series<double>(this, MaximumBarsLookBack.Infinite);
streakRsi = RSI(streak, StreakRSIPeriod, StreakRSISmoothing); streakRsi = RSI(streak, StreakRSIPeriod, RSISmoothing);
roc = ROC(1); roc = ROC(1);
percentRankReturns = PercentRank(roc, PercentRankPeriod); percentRankReturns = PercentRank(roc, PercentRankPeriod);
@ -97,19 +97,11 @@ namespace NinjaTrader.NinjaScript.Indicators
public int RSIPeriod { get; set; } public int RSIPeriod { get; set; }
[NinjaScriptProperty] [NinjaScriptProperty]
[Display(Name = "RSI Smoothing", GroupName = "ConnorsRSI", Order = 2)] [Display(Name = "Streak RSI Period", GroupName = "ConnorsRSI", Order = 2)]
public int RSISmoothing { get; set; }
[NinjaScriptProperty]
[Display(Name = "Streak RSI Period", GroupName = "ConnorsRSI", Order = 3)]
public int StreakRSIPeriod { get; set; } public int StreakRSIPeriod { get; set; }
[NinjaScriptProperty] [NinjaScriptProperty]
[Display(Name = "Streak RSI Smoothing", GroupName = "ConnorsRSI", Order = 4)] [Display(Name = "Percent Rank Period", GroupName = "ConnorsRSI", Order = 3)]
public int StreakRSISmoothing { get; set; }
[NinjaScriptProperty]
[Display(Name = "Percent Rank Period", GroupName = "ConnorsRSI", Order = 5)]
public int PercentRankPeriod { get; set; } public int PercentRankPeriod { get; set; }
} }
} }
@ -121,18 +113,18 @@ namespace NinjaTrader.NinjaScript.Indicators
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{ {
private ConnorsRSI[] cacheConnorsRSI; private ConnorsRSI[] cacheConnorsRSI;
public ConnorsRSI ConnorsRSI(int rSIPeriod, int rSISmoothing, int streakRSIPeriod, int streakRSISmoothing, int percentRankPeriod) public ConnorsRSI ConnorsRSI(int rSIPeriod, int streakRSIPeriod, int percentRankPeriod)
{ {
return ConnorsRSI(Input, rSIPeriod, rSISmoothing, streakRSIPeriod, streakRSISmoothing, percentRankPeriod); return ConnorsRSI(Input, rSIPeriod, streakRSIPeriod, percentRankPeriod);
} }
public ConnorsRSI ConnorsRSI(ISeries<double> input, int rSIPeriod, int rSISmoothing, int streakRSIPeriod, int streakRSISmoothing, int percentRankPeriod) public ConnorsRSI ConnorsRSI(ISeries<double> input, int rSIPeriod, int streakRSIPeriod, int percentRankPeriod)
{ {
if (cacheConnorsRSI != null) if (cacheConnorsRSI != null)
for (int idx = 0; idx < cacheConnorsRSI.Length; idx++) for (int idx = 0; idx < cacheConnorsRSI.Length; idx++)
if (cacheConnorsRSI[idx] != null && cacheConnorsRSI[idx].RSIPeriod == rSIPeriod && cacheConnorsRSI[idx].RSISmoothing == rSISmoothing && cacheConnorsRSI[idx].StreakRSIPeriod == streakRSIPeriod && cacheConnorsRSI[idx].StreakRSISmoothing == streakRSISmoothing && cacheConnorsRSI[idx].PercentRankPeriod == percentRankPeriod && cacheConnorsRSI[idx].EqualsInput(input)) if (cacheConnorsRSI[idx] != null && cacheConnorsRSI[idx].RSIPeriod == rSIPeriod && cacheConnorsRSI[idx].StreakRSIPeriod == streakRSIPeriod && cacheConnorsRSI[idx].PercentRankPeriod == percentRankPeriod && cacheConnorsRSI[idx].EqualsInput(input))
return cacheConnorsRSI[idx]; return cacheConnorsRSI[idx];
return CacheIndicator<ConnorsRSI>(new ConnorsRSI(){ RSIPeriod = rSIPeriod, RSISmoothing = rSISmoothing, StreakRSIPeriod = streakRSIPeriod, StreakRSISmoothing = streakRSISmoothing, PercentRankPeriod = percentRankPeriod }, input, ref cacheConnorsRSI); return CacheIndicator<ConnorsRSI>(new ConnorsRSI(){ RSIPeriod = rSIPeriod, StreakRSIPeriod = streakRSIPeriod, PercentRankPeriod = percentRankPeriod }, input, ref cacheConnorsRSI);
} }
} }
} }
@ -141,14 +133,14 @@ namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{ {
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{ {
public Indicators.ConnorsRSI ConnorsRSI(int rSIPeriod, int rSISmoothing, int streakRSIPeriod, int streakRSISmoothing, int percentRankPeriod) public Indicators.ConnorsRSI ConnorsRSI(int rSIPeriod, int streakRSIPeriod, int percentRankPeriod)
{ {
return indicator.ConnorsRSI(Input, rSIPeriod, rSISmoothing, streakRSIPeriod, streakRSISmoothing, percentRankPeriod); return indicator.ConnorsRSI(Input, rSIPeriod, streakRSIPeriod, percentRankPeriod);
} }
public Indicators.ConnorsRSI ConnorsRSI(ISeries<double> input , int rSIPeriod, int rSISmoothing, int streakRSIPeriod, int streakRSISmoothing, int percentRankPeriod) public Indicators.ConnorsRSI ConnorsRSI(ISeries<double> input , int rSIPeriod, int streakRSIPeriod, int percentRankPeriod)
{ {
return indicator.ConnorsRSI(input, rSIPeriod, rSISmoothing, streakRSIPeriod, streakRSISmoothing, percentRankPeriod); return indicator.ConnorsRSI(input, rSIPeriod, streakRSIPeriod, percentRankPeriod);
} }
} }
} }
@ -157,14 +149,14 @@ namespace NinjaTrader.NinjaScript.Strategies
{ {
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{ {
public Indicators.ConnorsRSI ConnorsRSI(int rSIPeriod, int rSISmoothing, int streakRSIPeriod, int streakRSISmoothing, int percentRankPeriod) public Indicators.ConnorsRSI ConnorsRSI(int rSIPeriod, int streakRSIPeriod, int percentRankPeriod)
{ {
return indicator.ConnorsRSI(Input, rSIPeriod, rSISmoothing, streakRSIPeriod, streakRSISmoothing, percentRankPeriod); return indicator.ConnorsRSI(Input, rSIPeriod, streakRSIPeriod, percentRankPeriod);
} }
public Indicators.ConnorsRSI ConnorsRSI(ISeries<double> input , int rSIPeriod, int rSISmoothing, int streakRSIPeriod, int streakRSISmoothing, int percentRankPeriod) public Indicators.ConnorsRSI ConnorsRSI(ISeries<double> input , int rSIPeriod, int streakRSIPeriod, int percentRankPeriod)
{ {
return indicator.ConnorsRSI(input, rSIPeriod, rSISmoothing, streakRSIPeriod, streakRSISmoothing, percentRankPeriod); return indicator.ConnorsRSI(input, rSIPeriod, streakRSIPeriod, percentRankPeriod);
} }
} }
} }