From 7603e7cf3677b8d77232b15c2afb1ec535c5cf95 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Wed, 25 Sep 2024 10:21:28 -0700 Subject: [PATCH] Re-organize conditions in 3-Day High / Low strategy in order to properly perform aggressive entries --- .../3-day-high-low/ThreeDayHighLowBot.cs | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/strategies/3-day-high-low/ThreeDayHighLowBot.cs b/strategies/3-day-high-low/ThreeDayHighLowBot.cs index 7e75d70..4f6436c 100644 --- a/strategies/3-day-high-low/ThreeDayHighLowBot.cs +++ b/strategies/3-day-high-low/ThreeDayHighLowBot.cs @@ -43,38 +43,30 @@ namespace NinjaTrader.NinjaScript.Strategies if (EnableLongTrades) { - if (Close[0] > longTermTrend[0] && Close[0] < shortTermTrend[0]) - { - if (IsConsecutiveLowerHighsAndLows(ConsecutiveDays)) - { - if (Position.MarketPosition == MarketPosition.Flat) - EnterLong(); - else if (Position.MarketPosition == MarketPosition.Long && Close[0] < Position.AveragePrice - && EnableAggressiveEntries) - EnterLong(); - } - } - if (Position.MarketPosition == MarketPosition.Long && Close[0] > shortTermTrend[0]) ExitLong(); + else if (Close[0] > longTermTrend[0]) + { + if (IsConsecutiveLowerHighsAndLows(ConsecutiveDays) && Close[0] < shortTermTrend[0] && Position.MarketPosition == MarketPosition.Flat) + EnterLong(); + + if (EnableAggressiveEntries && Position.MarketPosition == MarketPosition.Long && Close[0] < Position.AveragePrice) + EnterLong(); + } } if (EnableShortTrades) { - if (Close[0] < longTermTrend[0] && Close[0] > shortTermTrend[0]) - { - if (IsConsecutiveHigherHighsAndLows(ConsecutiveDays)) - { - if (Position.MarketPosition == MarketPosition.Flat) - EnterShort(); - else if (Position.MarketPosition == MarketPosition.Short && Close[0] > Position.AveragePrice - && EnableAggressiveEntries) - EnterShort(); - } - } - if (Position.MarketPosition == MarketPosition.Short && Close[0] < shortTermTrend[0]) ExitShort(); + else if (Close[0] < longTermTrend[0]) + { + if (IsConsecutiveHigherHighsAndLows(ConsecutiveDays) && Close[0] > shortTermTrend[0] && Position.MarketPosition == MarketPosition.Flat) + EnterShort(); + + if (EnableAggressiveEntries && Position.MarketPosition == MarketPosition.Short && Close[0] > Position.AveragePrice) + EnterShort(); + } } }