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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X