Add RSI period and smoothing properties to RSI divergence strategy

This commit is contained in:
moshferatu 2024-08-31 06:15:18 -07:00
parent 5562b05589
commit 9e0590bad7

View File

@ -1,6 +1,7 @@
#region Using declarations #region Using declarations
using NinjaTrader.Cbi; using NinjaTrader.Cbi;
using NinjaTrader.NinjaScript.Indicators; using NinjaTrader.NinjaScript.Indicators;
using System.ComponentModel.DataAnnotations;
#endregion #endregion
namespace NinjaTrader.NinjaScript.Strategies namespace NinjaTrader.NinjaScript.Strategies
@ -31,10 +32,13 @@ namespace NinjaTrader.NinjaScript.Strategies
StopTargetHandling = StopTargetHandling.PerEntryExecution; StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20; BarsRequiredToTrade = 20;
IsInstantiatedOnEachOptimizationIteration = true; IsInstantiatedOnEachOptimizationIteration = true;
RSIPeriod = 14;
RSISmoothing = 3;
} }
else if (State == State.DataLoaded) else if (State == State.DataLoaded)
{ {
rsi = RSI(14, 3); rsi = RSI(RSIPeriod, RSISmoothing);
} }
} }
@ -54,5 +58,15 @@ namespace NinjaTrader.NinjaScript.Strategies
{ {
get { return Name; } get { return Name; }
} }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "RSI Period", GroupName = "RSI Divergence Bot", Order = 1)]
public int RSIPeriod { get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "RSI Smoothing", GroupName = "RSI Divergence Bot", Order = 2)]
public int RSISmoothing { get; set; }
} }
} }