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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        47 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        15 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        21 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X