Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnExecution Stops

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    OnExecution Stops

    I have a strategy based on the OnExecution reference sample and when I change the stop order to a trailing stop in the OnBarUpdate section it leaves me with 2 stops (the original stop and the trail stop). In an effort to fix this do I just name the stop the same name in each section or how is the best way to fix this? Basically I want to ammend the OnExecution stop order to the OnBarUpdate stop price after a certain amount of profit is gained.

    Code:
    protected override void OnBarUpdate()
    {
    stopOrder = ExitLongStop(0, true, 1, Math.Min(myLongStop,GetCurrentBid(0)), "[B]myLongTrailStop[/B]", "myLongEntry");
    }
    
    protected override void OnExecution(IExecution execution)
          {
           if(Position.MarketPosition==MarketPosition.Long)
                {
                stopOrder = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - (20*TickSize), "[B]myLongTrailStop"[/B], "myLongEntry");
                }
          }
    Thank you for the help!

    GT

    #2
    Hi GT, for the correct order tracking I'd suggest to work with IOrder objects - http://www.ninjatrader-support.com/H...V6/IOrder.html

    Basically you want then to submit your order in the OnExecution and modify the trailprice in the OnBarUpdate() as the trade progresses.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    57 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    143 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X