Initial commit of Lower Lows strategy

This commit is contained in:
moshferatu 2024-10-15 10:00:15 -07:00
parent 3783cc1a83
commit e7c7c7ead9

View File

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