I am trying to have a trail stop that follow the price of the candle and not updating at candle close
as you can see in the picture entry @ 22104 original stop @ 22074 - the current price of the is 22109 so 5 tick higher and even higher since the high of the candle is higher than the current price - the trail stop should move the same.
I watch the candle move and also was looking at the order flow as well and the stop is getting updated only at close not during
here the sample code I am using
namespace NinjaTrader.NinjaScript.Strategies { public class MyCustomStrategy1 : Strategy { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Strategy here."; Name = "MyCustomStrategy1"; 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; } else if (State == State.Configure) { SetTrailStop("", CalculationMode.Ticks, 30, false); } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) return; // Set 1 if (Close[0] > Open[0]) { EnterLong(Convert.ToInt32(DefaultQuantity), ""); } } } }
Comment