From e7c7c7ead93530b4c9c8dae0a88893c171e700bf Mon Sep 17 00:00:00 2001 From: moshferatu Date: Tue, 15 Oct 2024 10:00:15 -0700 Subject: [PATCH] Initial commit of Lower Lows strategy --- .../higher-highs-and-lower-lows/LowerLows.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 strategies/higher-highs-and-lower-lows/LowerLows.cs diff --git a/strategies/higher-highs-and-lower-lows/LowerLows.cs b/strategies/higher-highs-and-lower-lows/LowerLows.cs new file mode 100644 index 0000000..90f28fe --- /dev/null +++ b/strategies/higher-highs-and-lower-lows/LowerLows.cs @@ -0,0 +1,62 @@ +#region Using declarations +using System.ComponentModel.DataAnnotations; +using NinjaTrader.NinjaScript.Indicators; +#endregion + +namespace NinjaTrader.NinjaScript.Strategies +{ + public class LowerLows : Strategy + { + private SMA longTermTrend; + + private int lowerLowStreak; + + protected override void OnStateChange() + { + if (State == State.SetDefaults) + { + Name = "Lower Lows"; + Description = @"Based on chatper 3 of How Markets Really Work (2012) by Larry Connors"; + Calculate = Calculate.OnBarClose; + EntriesPerDirection = 1; + + ConsecutiveLowerLows = 3; + LongTermTrendPeriod = 200; + } + else if (State == State.DataLoaded) + { + longTermTrend = SMA(LongTermTrendPeriod); + } + } + + protected override void OnBarUpdate() + { + if (CurrentBar < ConsecutiveLowerLows) + return; + + if (Low[0] < Low[1]) + lowerLowStreak++; + else + lowerLowStreak = 0; + + if (lowerLowStreak >= ConsecutiveLowerLows) + EnterLong(); + + if (BarsSinceEntryExecution() >= 5) + ExitLong(); + } + + public override string DisplayName + { + get { return Name; } + } + + [NinjaScriptProperty] + [Display(Name = "Consecutive Lower Lows", GroupName = "Lower Lows", Order = 1)] + public int ConsecutiveLowerLows { get; set; } + + [NinjaScriptProperty] + [Display(Name = "Long-Term Trend Period", GroupName = "Lower Lows", Order = 2)] + public int LongTermTrendPeriod { get; set; } + } +}