I used ninzaRenko 40/1. Below is the code i used. Can anyone guide me why backtest is filling orders correctly but real time trades orders are filling differently.
Attachment1 - real time trades where orders are filling incorrectly.
Attachment2 - backtest trades working correctly.
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Strategy here."; Name = "HTScalper"; 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; // Disable this property for performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = true; ProfitTarget = 36; StopLoss = 100; Lot = 1; lastTradeTaken = TradeType.None; TradeOnlyNWSession = true; } else if (State == State.Configure) { } else if (State == State.DataLoaded) { HalfTrend1 = HalfTrend(Close, 2, 2, 100, false, true, 10); ninZaHalfTrendPro1 = ninZaHalfTrendPro(Close, 3, ninZa_MAType.LinReg, true, ninZa_MAType.EMA, 3, 1, 100); SetProfitTarget("", CalculationMode.Ticks, ProfitTarget); SetStopLoss("", CalculationMode.Ticks, StopLoss, false); } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) return; // Set 1 if (ninZaHalfTrendPro1.Signal_Trend[0] == 1) { EnterLong(Convert.ToInt32(Lot), ""); } // Set 2 if (ninZaHalfTrendPro1.Signal_Trend[0] == -1) { EnterShort(Convert.ToInt32(Lot), ""); } }
Comment