From 9cbd81feb630c0c7b7f7297922d008b5ba816faa Mon Sep 17 00:00:00 2001 From: moshferatu Date: Mon, 18 Nov 2024 06:33:13 -0800 Subject: [PATCH] Initial commit of Large Moves Up strategy --- strategies/large-moves/LargeMovesUp.cs | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 strategies/large-moves/LargeMovesUp.cs diff --git a/strategies/large-moves/LargeMovesUp.cs b/strategies/large-moves/LargeMovesUp.cs new file mode 100644 index 0000000..176d636 --- /dev/null +++ b/strategies/large-moves/LargeMovesUp.cs @@ -0,0 +1,46 @@ +#region Using declarations +using System.ComponentModel.DataAnnotations; +#endregion + +namespace NinjaTrader.NinjaScript.Strategies +{ + public class LargeMovesUp : Strategy + { + protected override void OnStateChange() + { + if (State == State.SetDefaults) + { + Name = "Large Moves Up"; + Description = @"Based on chatper 7 of How Markets Really Work (2012) by Larry Connors"; + Calculate = Calculate.OnBarClose; + EntriesPerDirection = 1; + + PercentGainThreshold = 1.0; + DaysToExit = 5; + } + } + + protected override void OnBarUpdate() + { + double percent_gain = (Close[0] - Open[0]) / Open[0] * 100; + if (percent_gain >= PercentGainThreshold) + EnterLong(); + + if (BarsSinceEntryExecution() >= DaysToExit) + ExitLong(); + } + + public override string DisplayName + { + get { return Name; } + } + + [NinjaScriptProperty] + [Display(Name = "Percent Gain", GroupName = "Large Moves Up", Order = 1)] + public double PercentGainThreshold { get; set; } + + [NinjaScriptProperty] + [Display(Name = "Days to Exit", GroupName = "Large Moves Up", Order = 2)] + public int DaysToExit { get; set; } + } +}