Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question on A reference Sample

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

    Question on A reference Sample

    I have a question of the reference sample:

    Strategy: Using OnOrderUpdate() and OnExecution() methods to submit protective orders

    I assume the point of the example is to show how to submit stops and targets in the OnExecution method--but in the reference the stopOrder is submitted in the OnBarUpdate method once price has moved 4 ticks in our favor

    Is there a reason that the stopOrder is submitted in the OnBarUpdate method and not in the OnExecution method? Is it because we can't get the 'last' trade price (Close[0]) in the OnExecution method?

    I am not clear when to use OnBarUpdate vs. OnExecution (I realize that OnBarUpdate is triggered either at the start of a new bar or by tick-by-tick depending on CalculateOnBarClose setting while the OnExecution is triggered on Order executions)--but seems like if the point is to submit changes in stop orders or targets as soon as possible-that we would always use OnExecution.

    So could you expand on when you should NOT use OnExecution methods to handle changes in stop orders, etc.

    thanks.
    Jim-Boulder
    NinjaTrader Ecosystem Vendor - Elephant Tracks

    #2
    Jim, the stopOrder is submitted for the exact reason you've listed. OnExecution() has no idea of the current bars on the chart, so it doesn't know prices. This is why it must be called from OnBarUpdate(), so it can grab the chart prices to place the order at the appropriate place.

    OnExecution() should only be used when the order you're trying to submit depends on the fill (or unfilled) status of another order. It should not be used in many other situations. For example, if you're trying to modify the price of a trailing stop order, that would not be an OnExecution() thing; it would occur in OnBarUpdate() (or OnMarketData() or something like that).

    Please let us know if you have any other questions.
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    575 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X