From 8fc49bf60dbe3d33a0c91dfebebc8a5cd18ee973 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Sat, 31 Aug 2024 06:18:21 -0700 Subject: [PATCH] Add a configuration property to the RSI divergence strategy for setting the divergence period --- strategies/rsi-divergence/RSIDivergenceBot.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/strategies/rsi-divergence/RSIDivergenceBot.cs b/strategies/rsi-divergence/RSIDivergenceBot.cs index 00dcb4b..c7f9196 100644 --- a/strategies/rsi-divergence/RSIDivergenceBot.cs +++ b/strategies/rsi-divergence/RSIDivergenceBot.cs @@ -35,6 +35,7 @@ namespace NinjaTrader.NinjaScript.Strategies RSIPeriod = 14; RSISmoothing = 3; + DivergencePeriod = 5; } else if (State == State.DataLoaded) { @@ -47,7 +48,7 @@ namespace NinjaTrader.NinjaScript.Strategies if (CurrentBar < BarsRequiredToTrade) return; - if (rsi[0] > rsi[5] && Close[0] < Close[5]) + if (rsi[0] > rsi[DivergencePeriod] && Close[0] < Close[DivergencePeriod]) EnterLong(); if (Position.MarketPosition == MarketPosition.Long && rsi[0] > 70.0) @@ -68,5 +69,10 @@ namespace NinjaTrader.NinjaScript.Strategies [Range(1, int.MaxValue)] [Display(Name = "RSI Smoothing", GroupName = "RSI Divergence Bot", Order = 2)] public int RSISmoothing { get; set; } + + [NinjaScriptProperty] + [Range(1, int.MaxValue)] + [Display(Name = "Divergence Period", GroupName = "RSI Divergence Bot", Order = 3)] + public int DivergencePeriod { get; set; } } }