Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Backtesting is not entering on correct bar

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

    Backtesting is not entering on correct bar

    Hi, Whenever I backtest my strategy, it executes the order properly, usually in the right place, but it's never on the correct candle. It always places the order one candle later than it should.

    The strategy setup works in real time and the order is placed on the correct candle, but not in when I run the strategy backtesting analyzer. Can you help me understand why it might be doing that?

    Cheers,
    Seastragg

    #2
    Hello Seastragg,

    When NinjaTrader is running with Calculate set to OnBarClose, orders are placed after the bar closes using logic calculated from that bar.

    Below is a link to the help guide on the Calculate property.
    http://ninjatrader.com/support/helpG.../calculate.htm

    This means that any orders that are triggered from that bar are submitted after the bar closes as the new bar opens. As the order is placed as the new bar opens and the timestamp of the order is within the time of the next bar, the order will show on the next bar.

    If the strategy were running with Calculate as OnPriceChange or OnEachTick, or if the script has intra-bar granularity and submitted orders on a smaller timeframe, this would cause the timestamp of the order to be within the bar it is triggered on as the order may be submitted intra-bar. This order would show on the same bar as the bar that triggered the order submission.

    This is outlined in the help guide Discrepancies: Real-Time vs Backtest.
    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    Also, below is a link to a forum thread about intra-bar granularity.
    http://ninjatrader.com/support/forum...297#post491297
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Goodgood, Today, 05:59 PM
    1 response
    20 views
    0 likes
    Last Post hunter548  
    Started by vpatanka, 09-22-2022, 06:48 PM
    3 responses
    23 views
    0 likes
    Last Post vpatanka  
    Started by brenthilburn, Today, 06:19 AM
    1 response
    18 views
    0 likes
    Last Post bltdavid  
    Started by artson, Today, 05:23 PM
    0 responses
    4 views
    1 like
    Last Post artson
    by artson
     
    Started by dtaylor, 09-16-2022, 03:38 PM
    4 responses
    37 views
    0 likes
    Last Post dtaylor
    by dtaylor
     
    Working...
    X