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

Can backtests be run with tick granularity or not?

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

    Can backtests be run with tick granularity or not?

    Can someone clarify...

    Discrepancies: Real-Time vs Backtest says:
    "During backtest, strategies can ONLY be processed at the close of each bar."

    But posts like...
    https://forum.ninjatrader.com/forum/...52#post1153252
    https://forum.ninjatrader.com/forum/...nce#post100192

    ..talk about adding 1-tick granularity to provide accuracy.

    So which is it? Can a backtest process on 1-tick basis, or only at the close of each bar?

    Also, for adding 1-tick processing, some posts like...
    https://forum.ninjatrader.com/forum/...19#post1220519
    https://forum.ninjatrader.com/forum/...55#post1229055

    ...mention "add a 1 tick series and submit your stop loss and profit target to this series"...as if simply setting the order fill processing to "High; Tick; 1" is not enough.

    Is the need to "add a series and submit targets to it" just out of date information?

    How does one get the most accurate real-world results in backtest?
    Last edited by tradgrad; 11-30-2023, 02:02 AM.

    #2
    Hello tradgrad,

    Thank you for your post.

    You can add Tick Replay with 1-tick intrabar granularity to allow logic to be processed intra-bar and have your orders fill intra bar.

    When in historical data (backtesting), only the Open, High, Low, and Close will be available and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

    Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

    Using Tick Replay with an added 1-tick data series will help improve the accuracy.

    Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single tick data series and submit orders to that single tick data series for a strategy that uses Tick Replay.

    High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.


    Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.

    SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm

    TickReplay - https://ninjatrader.com/support/help...ick_replay.htm

    Additional information may be found in this forum post:
    https://forum.ninjatrader.com/forum/...377#post773377

    Please let us know if we may be of further assistance.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Gaby

      So when the documentation says "During backtest, strategies can ONLY be processed at the close of each bar"...what it really means is "...unless you enable tick replay"?

      Also, it is stated in that forum post:
      Below is a link to an official reference sample that demonstrates how to add intra-bar granularity.
      'Backtesting NinjaScript Strategies with an intrabar granularity' https://ninjatrader.com/support/help...ipt_strate.htm

      And a link to a video demonstrating implementing 1-tick intra-bar granularity.
      https://drive.google.com/file/d/12F6...usp=share_link
      Those demonstrate altering a script manually.

      Is there any available instruction or video demonstrating how to do this within Strategy Builder?

      Comment


        #4
        Hello,

        Right, from the Help Guide on Calculate:

        "On a historical data set, only the OHLCVT of the bar is known and not each tick that made up the bar. As a result, State.Historical data processes OnBarUpdate() only on the close of each historical bar even if this property is set to OnEachTick or OnPriceChange. You can use TickReplay or a Multi-time frame script to obtain intrabar data."

        https://ninjatrader.com/support/help.../calculate.htm

        You would not be able to accomplish adding intrabar granularity using the Strategy Builder. This requires unlocking your code from the Strategy Builder using the 'Unlock code' button and then manually coding this into your strategy.

        Please let me know if you have any other questions.
        Gaby V.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,404 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        95 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        159 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X