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; } + } +}