Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Orders are shifted one day

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

    Orders are shifted one day

    Hello,

    I defined a strategy. I could not understand why all orders are submitted on the day after at opening instead of being submitted on Close of current day.
    For example:
    - Long order condition is the following
    Code:
     if ((CrossAbove(Close, EMA(aaa(Close, 6).Plot0, 6), 1)) && (Close[0] >= MAX(Close, 5)[0]))
                {
                    int Nb = (int)Math.Round(2.7*MyAccountSize/Close[0]);
                    entryOrder = EnterLong(Nb, "Long");   
                }
    - on attached picture, i expect order to be applied on close, just after crossing orange plot (correspond to EMA(aaa(Close, 6).Plot0, 6)), but it is not the case.

    Thanks in advance for your help
    Attached Files

    #2
    Hi LaughingDwarf,

    This is expected timing of orders when running the strategy historically, or when CalculateOnBarClose = true.

    Conditions are evaluated at the close of the bar. If true, they are submitted to the next bar. Market orders are filled at the open of the next bar following the condition.

    In real time with CalculateOnBarClose = false, conditions are evaluated with every incoming tick, and orders are submitted immediately when conditions evaluate true.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      Thank you for this quick answer.
      Would it be possible to add that functionnality so that historical trades and trades are as much close as possible from real trades when CalculateOnBarClose = false. Or is there a functional restriction from providing that?

      Comment


        #4
        In historical sense, all bar processing takes place on bar close, but you can add a secondary series that is smaller than the first. This allows you increased granularity when backtesting. We have a sample available that demonstrates this approach here:
        You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
        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
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X