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

Intra Bar trading backtest revisit

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

    Intra Bar trading backtest revisit

    Hello,

    I was reading the intrabar backtesting thread but got a little confused. I am developing NT8 strategy which involves Intra-bar trading. I am fairly clear about how Calculate.OnEachTick and Calculate.OnPriceChange will behave in live trading, but still not 100% sure how they will behave in backtesting running my strategy in StrategyAnalyzer. Could you kindly summarize the differences between live and backtesting in StrategyAnalyzer for the intrabar trades? Thank you very much.

    #2
    Hello billythekid72,

    Thanks for the post.

    The OnEachTick and OnPriceChange won't work historically so that would be about the most simple summary I could provide here. A script always runs OnBarClose in historical/backtesting so you can exclude those two modes from any testing/questions for backtesting as they won't apply.

    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.
    When using intrabar granularity like the sample here: https://ninjatrader.com/support/help...ipt_strate.htm
    That is essentially just running a secondary series which is more granular that the primary, that allows for more datapoints within the primary bars timespan so the orders have that extra data for fills. The orders are specifically submitted to that sereis in this case. You can also use the added granularity for indicators or for calling logic at a higher frequency.

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      Thank you for your prompt reply, this is exactly where my confusions come in.

      While I know that "OnEachTick and OnPriceChange won't work historically", however the "intrabar granularity " example seems to suggest in fact we can get intraday granularity even in historical backtesting, just that it has to be achieved via second data series? What if our primary data series is ticks based (2000 ticks per bar to be exact)? Thank you for your help.

      Comment


        #4
        Hello billythekid72,

        Yes if you are using a Daily bar you can add a intraday series as a secondary. Intraday granularity would simply mean a series that is less than a Daily bar. Adding a secondary series won't specifically add intraday granularity unless the primary was a daily series and you are adding a smaller timeframe lime 1 minute. If you instead have two similar intraday series like tick series that would just mean you are adding a more granular secondary series.

        If your primary is 2000 ticks that means frequency OnBarUpdate is called will be every 2000 ticks. That is the fastest you can see orders fill at or the 2000 tick bar frequency. We also only know the OHLCV from the 2000 tick bar.

        If you add a second series at 1000 ticks you now have twice the granularity of your primary. That can allow for an order to fill either after the first 1000 tick bar or the second or twice the chance that it had with the primary.

        The OnEachTick and OnPriceChange are specific realtime calculation modes, this deals with how OnBarUpdate is being called. In historical we will always see the frequency of 2000 ticks for that primary no matter what you have set. In realtime you could see the frequencies of 2000, 1 tick, or OnPriceChange depending on what is used.


        I look forward to being of further assistance.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          Got it. So in summary, if my primary data series is 2000 ticks, and my secondary data series is set to 1 tick (for example), OnBarUpdate will happen for every tick (in addition to the 2000 tick bar update), and this happens in BOTH live and backtest situations. Is my understanding correct? Thanks for your help.

          Comment


            #6
            Hello billythekid72,

            Right, if you set OnBarClose to match historical it would be the same. You would have 1 tick frequency updates for BarsInProgress 1 and 2000 tick bars for the primary BarsInProgress 0.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hello Jesse,

              Thank you for the clarification, one last question In the case of one-click granular secondary data series, OnBarUpdate gets a call for every tick, we will have access to the Bar object and its method calls, and also able to enter and exit order, is that correct. Thank you very much for your help.

              Comment


                #8
                Hello billythekid72,

                I am not certain I understand how you worded this but yes you will be able to execute the order logic at 1 tick frequency in that use case.
                You would have access to the OHLC values for that tick if that is what you mean by bar object here.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Aviram Y, Today, 05:29 AM
                0 responses
                2 views
                0 likes
                Last Post Aviram Y  
                Started by quantismo, 04-17-2024, 05:13 PM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                7 responses
                34 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cls71, Today, 04:45 AM
                0 responses
                6 views
                0 likes
                Last Post cls71
                by cls71
                 
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                217 views
                1 like
                Last Post PaulMohn  
                Working...
                X