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 cmoran13, Yesterday, 01:02 PM
    0 responses
    29 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    21 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    95 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    148 views
    2 likes
    Last Post CaptainJack  
    Working...
    X