From b821a6da24da38b1a61307823e58d94c43221dcd Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 5 Sep 2024 04:43:13 -0700 Subject: [PATCH] Add a configuration setting for position size to daily reversal strategy --- strategies/daily-reversal/DailyReversalBot.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/strategies/daily-reversal/DailyReversalBot.cs b/strategies/daily-reversal/DailyReversalBot.cs index 29b09b7..b1aca71 100644 --- a/strategies/daily-reversal/DailyReversalBot.cs +++ b/strategies/daily-reversal/DailyReversalBot.cs @@ -2,6 +2,7 @@ using NinjaTrader.Cbi; using NinjaTrader.Data; using System; +using System.ComponentModel.DataAnnotations; #endregion namespace NinjaTrader.NinjaScript.Strategies @@ -35,6 +36,8 @@ namespace NinjaTrader.NinjaScript.Strategies StopTargetHandling = StopTargetHandling.PerEntryExecution; BarsRequiredToTrade = 2; IsInstantiatedOnEachOptimizationIteration = true; + + PositionSize = 10000; } else if (State == State.Configure) { @@ -53,7 +56,7 @@ namespace NinjaTrader.NinjaScript.Strategies return; // Using fixed position sizing to account for lower index values in the past. - int quantity = (int)Math.Floor(10000 / Close[0]); + int quantity = (int)Math.Floor(PositionSize / Close[0]); if (Lows[PrimaryBars][0] < Lows[PrimaryBars][1] && Highs[PrimaryBars][0] < Highs[PrimaryBars][1]) { @@ -66,5 +69,11 @@ namespace NinjaTrader.NinjaScript.Strategies if (ToTime(Time[0]) == ToTime(sessionClose.AddMinutes(-1))) ExitLong(); } + + [NinjaScriptProperty] + [Range(1, int.MaxValue)] + [Display(Name = "Position Size", GroupName = "Daily Reversal Bot", Order = 1)] + public int PositionSize + { get; set; } } }