diff --git a/strategies/bearish-engulfing/BearishEngulfingBot.cs b/strategies/bearish-engulfing/BearishEngulfingBot.cs new file mode 100644 index 0000000..a57b78f --- /dev/null +++ b/strategies/bearish-engulfing/BearishEngulfingBot.cs @@ -0,0 +1,55 @@ +#region Using declarations +using NinjaTrader.Cbi; +using System; +#endregion + +namespace NinjaTrader.NinjaScript.Strategies +{ + public class BearishEngulfingBot : Strategy + { + protected override void OnStateChange() + { + if (State == State.SetDefaults) + { + Description = @""; + Name = "Bearish Engulfing Bot"; + Calculate = Calculate.OnBarClose; + EntriesPerDirection = 1; + EntryHandling = EntryHandling.AllEntries; + IsExitOnSessionCloseStrategy = true; + ExitOnSessionCloseSeconds = 30; + IsFillLimitOnTouch = false; + MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix; + OrderFillResolution = OrderFillResolution.Standard; + Slippage = 0; + StartBehavior = StartBehavior.WaitUntilFlat; + TimeInForce = TimeInForce.Gtc; + TraceOrders = false; + RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose; + StopTargetHandling = StopTargetHandling.PerEntryExecution; + BarsRequiredToTrade = 20; + IsInstantiatedOnEachOptimizationIteration = true; + } + else if (State == State.Configure) + { + } + } + + protected override void OnBarUpdate() + { + if (CurrentBar < BarsRequiredToTrade) + return; + + if (Close[1] > Open[1] && Open[0] > Close[1] && Close[0] < Open[1]) + EnterLong(); + + if (Position.MarketPosition == MarketPosition.Long && Close[0] > High[1]) + ExitLong(); + } + + public override string DisplayName + { + get { return Name; } + } + } +}