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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    64 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    35 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    51 views
    0 likes
    Last Post CarlTrading  
    Working...
    X