Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Difference market order historical and live trading

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

    Difference market order historical and live trading

    In a strategy I want to execute a market order if the currentprice exceeds a triggerlevel. This cause a difference between historical backtest and live trading.

    The code is simple:
    if (High[0] > Trigger[0]) {
    SubmitOrder(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", LongTradeTag.ToString() + "OL"); // Unmanaged approach
    }

    Between historical and live there is a shift of the order of 1 bar. In live trading the order is executed 1 bar earlier than in backtesting (the orderprice is not the issue, because I can change that within the Fill-procedure). In the backtest I expected that the code is calculated on the close and that order is triggered on that bar, but it seems that the order is triggered on the next bar. (I know there is a way to use a OrderType.Stop on the previous bar, but there are several reason that I need a market order).

    Is there a way to overcome this, so that in the backtest the order is also executed on the current bar? Look forward to your reply.

    Kind regards,
    Rene


    #2
    Rene, in backtesting orders would be always placed for the next bar, as the point when you place it would only be seen if the bars that triggered the order has closed, then you are technically already on the next bar open.

    For simulating intrabar fills, you could look into submitting the order to a finer added series as done here in this reference sample - http://www.ninjatrader.com/support/f...ead.php?t=6652

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    639 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X