63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
#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; }
|
|
}
|
|
}
|