diff --git a/strategies/turnaround/TurnaroundBot.cs b/strategies/turnaround/TurnaroundBot.cs new file mode 100644 index 0000000..e0f9eda --- /dev/null +++ b/strategies/turnaround/TurnaroundBot.cs @@ -0,0 +1,49 @@ +#region Using declarations +using NinjaTrader.Cbi; +using System; +#endregion + +namespace NinjaTrader.NinjaScript.Strategies +{ + public class TurnaroundBot : Strategy + { + protected override void OnStateChange() + { + if (State == State.SetDefaults) + { + Description = @"Turnaround Tuesday / Wednesday"; + Name = "Turnaround 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; + } + } + + protected override void OnBarUpdate() + { + if (CurrentBar < BarsRequiredToTrade) return; + + // Entry + if ((Time[0].DayOfWeek == DayOfWeek.Monday || Time[0].DayOfWeek == DayOfWeek.Tuesday) && + Close[0] < Close[1] && Close[1] < Close[2]) + EnterLong(); + + // Exit + if (Position.MarketPosition == MarketPosition.Long && Close[0] > High[1]) + ExitLong(); + } + } +}