Initial commit of Lower Lows strategy
This commit is contained in:
parent
3783cc1a83
commit
e7c7c7ead9
62
strategies/higher-highs-and-lower-lows/LowerLows.cs
Normal file
62
strategies/higher-highs-and-lower-lows/LowerLows.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user