Initial commit of Large Moves Down strategy
This commit is contained in:
parent
9cbd81feb6
commit
7a717cd0f0
46
strategies/large-moves/LargeMovesDown.cs
Normal file
46
strategies/large-moves/LargeMovesDown.cs
Normal file
@ -0,0 +1,46 @@
|
||||
#region Using declarations
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
#endregion
|
||||
|
||||
namespace NinjaTrader.NinjaScript.Strategies
|
||||
{
|
||||
public class LargeMovesDown : Strategy
|
||||
{
|
||||
protected override void OnStateChange()
|
||||
{
|
||||
if (State == State.SetDefaults)
|
||||
{
|
||||
Name = "Large Moves Down";
|
||||
Description = @"Based on chatper 7 of How Markets Really Work (2012) by Larry Connors";
|
||||
Calculate = Calculate.OnBarClose;
|
||||
EntriesPerDirection = 1;
|
||||
|
||||
PercentDeclineThreshold = 1.0;
|
||||
DaysToExit = 5;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBarUpdate()
|
||||
{
|
||||
double percent_decline = (Open[0] - Close[0]) / Open[0] * 100;
|
||||
if (percent_decline >= PercentDeclineThreshold)
|
||||
EnterLong();
|
||||
|
||||
if (BarsSinceEntryExecution() >= DaysToExit)
|
||||
ExitLong();
|
||||
}
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get { return Name; }
|
||||
}
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "Percent Decline", GroupName = "Large Moves Down", Order = 1)]
|
||||
public double PercentDeclineThreshold { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "Days to Exit", GroupName = "Large Moves Down", Order = 2)]
|
||||
public int DaysToExit { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user