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 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