Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order sending time in Managed and Unmanaged approaches

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

    Order sending time in Managed and Unmanaged approaches

    Hello NT support,

    In the managed approach, I've noticed that the simulation does not check for fills until OnBarUpdate() is done. Thus, AFAIK, it doesn't matter if in OnBarUpdate() I first call EnterLongLimit(), and only than set the brackets using SetProfitTarget() and SetStopLoss(). Namely, The following are equivalent:

    Code:
    // Sample A is equivalent to...
    protected override void OnBarUpdate()
    {
       EnterLongLimit(Price);
    
       SetStopLoss(CalculationMode.Ticks, SlTicks);
       SetProfitTarget(CalculationMode.Ticks, PtTicks);
    }
    
    // ...Samle B
    protected override void OnBarUpdate()
    {   
       SetStopLoss(CalculationMode.Ticks, SlTicks);
       SetProfitTarget(CalculationMode.Ticks, PtTicks);
    
       EnterLongLimit(Price);
    }
    Two questions:
    • Is this also the case in real time? Namely, will the core wait until we leave OnBarUpdate() to actually send the orders?
    • How about the Unmanaged approach? Are the orders sent right-away, or only after we leave OnBarUpdate()?


    Thanks,
    Boaz

    #2
    Hi Boaz,

    Real time orders submitted with set will be submitted during the execution event of the entry order. Set statements would typically be made in Initialize, so they're preset before the entry takes place. You would only want to place these in OnBarUpdate() if you wanted dynamic movement like shown in this sample.

    The unmanaged approach doesn't change the timing, so if you're submitting them during OnBarUpdate(), that's when they'll be submitted. If you wanted to submit at other times, can look into this sample here on submitting protective orders using OnOrderUpdate(), OnExecution(). The principles in this sample can be used for both managed and unmanaged approach.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      I guess what I'm really asking is whether or not OnBarUpdate(), or any other event handler for that matter, is an atomic operation, namely, can its execution be preempted by some other event.

      Thanks,
      Boaz

      Comment


        #4
        No, it's called only on bar updates. In real time this can be with every transaction made when using CalculateOnBarClose = false. In historical or COBC = true, then it's called only when the bar is completed.

        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        650 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 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
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        577 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X