Add long and short entry threshold parameters to ConnorsRSI strategy

This commit is contained in:
moshferatu 2025-01-09 08:15:01 -08:00
parent b5c5029e8f
commit 506a0fe0a5

View File

@ -26,6 +26,8 @@ namespace NinjaTrader.NinjaScript.Strategies
RSIPeriod = 3;
StreakRSIPeriod = 2;
PercentRankPeriod = 100;
LongEntryThreshold = 15;
ShortEntryThreshold = 85;
LongTermTrendPeriod = 200;
ShortTermTrendPeriod = 5;
}
@ -43,9 +45,9 @@ namespace NinjaTrader.NinjaScript.Strategies
if (CurrentBar < Math.Max(LongTermTrendPeriod, PercentRankPeriod))
return;
if (Close[0] > longTermTrend[0] && connorsRSI[0] < 15)
if (Close[0] > longTermTrend[0] && connorsRSI[0] < LongEntryThreshold)
EnterLong();
else if (Close[0] < longTermTrend[0] && connorsRSI[0] > 85)
else if (Close[0] < longTermTrend[0] && connorsRSI[0] > ShortEntryThreshold)
EnterShort();
if (Position.MarketPosition == MarketPosition.Long && Close[0] > shortTermTrend[0])
@ -72,11 +74,19 @@ namespace NinjaTrader.NinjaScript.Strategies
public int PercentRankPeriod { get; set; }
[NinjaScriptProperty]
[Display(Name = "Long-Term Trend Period", GroupName = "ConnorsRSI Bot", Order = 4)]
[Display(Name = "Long Entry Threshold", GroupName = "ConnorsRSI Bot", Order = 4)]
public double LongEntryThreshold { get; set; }
[NinjaScriptProperty]
[Display(Name = "Short Entry Threshold", GroupName = "ConnorsRSI Bot", Order = 5)]
public double ShortEntryThreshold { get; set; }
[NinjaScriptProperty]
[Display(Name = "Long-Term Trend Period", GroupName = "ConnorsRSI Bot", Order = 6)]
public int LongTermTrendPeriod { get; set; }
[NinjaScriptProperty]
[Display(Name = "Short-Term Trend Period", GroupName = "ConnorsRSI Bot", Order = 5)]
[Display(Name = "Short-Term Trend Period", GroupName = "ConnorsRSI Bot", Order = 7)]
public int ShortTermTrendPeriod { get; set; }
}
}