• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tick replay backtest and order fill

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

    Tick replay backtest and order fill

    Hello, I'm not sure I understand the order fill concept.

    I have a strategy using OnMarketData (this is given, no way around that). To backtest this strategy, I seem to have no other option than using Tick Replay. I'm running backtests on 5 min timeframe and the orders (market orders by EntryLong, EntryShort) are filled only with 5 minute granularity, completely out of the market price at the moment the order has been placed. This of course completely ruins the results.

    Can you please advice, am I missing something, or is Ninjatrader not supporting this scenario at the moment? Is it possible to run the backtest with the setup above, and get correct trades? Thank you.

    #2
    Hello mantak007,

    Thanks for opening the thread.

    Historical fill processing in the Strategy Analyzer will use the primary data series to simulate order fills. To add intrabar granularity, most strategies can use High Order Fill Resolution with a single tick data series to have orders filled against a single tick data series.

    High Order Fill Resolution is not compatible with Tick Replay, so a Tick Replay strategy must add a single tick data series on its own and submit orders to that single tick data series for intrabar order fills.

    This is demonstrated in the backtesting intrabar granularity example. I'll provide a link and additional public reference for multi series NinjaScripts and Historical Fill Processing.

    Backtesting with intrabar granularity - https://ninjatrader.com/support/foru...ead.php?t=6652

    Multi Series NinjaScripts - https://ninjatrader.com/support/help...nstruments.htm

    Historical Fill Processing - https://ninjatrader.com/support/help...ical_fill_.htm

    Please let me know if I can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello Jim, is the approach described in "Backtesting with intrabar granularity" compatible with the OnMarketData()? My understanding is OnMarketData() is not called without Tick Reply enabled, or is it?

      Comment


        #4
        Hello mantak007,

        Yes it is. Tick Replay must be enabled to playback OnMarketData events historically. The approach in "Backtesting with intrabar granularity" adds an additional data series and submits orders to that data series, thus changing the data series used to fill the orders. OnMarketData() can still be used to call your order entry and exit methods.

        Please let us know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          OK, got it, all seems to work. Thank you.

          Comment


            #6
            Hi Jim, seems there is another issue. I'm successfully using the tick data series for entries, however the exits managed by SetStopLoss and SetProfitTarget are still executed on the primary data series, so in my case the exits are executed with 5 minute granularity and at a wrong price. Is there a way how to "attach" the SetStopLoss and SetProfitTarget management to the tick data series? If not, can you please submit a feature request for the development?

            Comment


              #7
              Hello mantak007,

              Yes, the Set methods will still use the primary data series and cannot specify a BarsInProgress to submit the order to. We have a feature request tracking interest in this and I will submit a vote on your behalf. The ticket ID is SFT-689.

              As with other feature requests, we cannot present an ETA as they are fulfilled based on the development team's schedule and priorities. Upon implementation the ticket ID can be found publicly on the Release Notes page of the help guide. I'll provide a link below.

              Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

              Currently, the advised approach is to use your own Exit methods that can specify a BarsInProgress index for intrabar granularity.

              If there is anything else we can do to help, please let us know.
              JimNinjaTrader Customer Service

              Comment


                #8
                As of NT8 8.0.16.3 has SFT-689 been incorporated into NT8?

                I find that if I use Tick Replay on a chart when looking at a historical backtest, I get dramatically better results with tick replay than without, even though I'm not using any indicators that need bid/ask data.
                This regardless of whether or not I use OrderFillResolution.High & specify a 1 tic BarsPeriodType.

                This is my 1st real strat in NT8 & I haven't done much live testing yet so am wondering if historical backtests results are at all accurate.

                Comment


                  #9
                  Hello saturntd,

                  SFT-689 has not been implemented at this time. Currently there are 3 votes behind the request. If there is more demand it will be more likely to be considered for implementation.

                  Tick Replay will allow NinjaScripts to Calculate with OnEachTick or with OnPriceChange in addition to allowing historical use of OnMarketData. This could explain a difference in performance that you are seeing as the signals will not be triggered OnBarClose.There are also known differences with order fills which should be noted comparing these features to standard backtests.

                  Another item to note is that Tick Replay is not compatible with High Order Fill Resolution, so order fills will still be simulated using "virtual bars" the same way they would be simulated with Standard Fill Resolution. If you would like to mix Tick Replay with High Order Fill Resolution, you will have to add an additional data series to submit your orders to. This would involve using Exit methods to specify the BarsInProgress index since the Set methods will still use the primary data series for order fills.

                  To better explain these discrepancies, I have included links to our documentation on discrepancies between Realtime and Backtesting. Please also see Understanding Historical Fill Processing linked in post #2. An example demonstrating submitting orders to an additional data series for intrabar granularity is also linked in post #2.

                  Discrepancies between Realtime and Backtesting - https://ninjatrader.com/support/help...ime_vs_bac.htm

                  Further notes for using Tick Replay are noted in the help guide page linked below.

                  Developing for Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

                  Let me know if you have any additional questions.
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Hello Jim,
                    Thanks for the response.
                    How can I vote for SFT-689?

                    Comment


                      #11
                      Hello saturntd,

                      You can let one of us know that you would like a vote added. I've also added a vote on your behalf.

                      Let me know if there is anything else I can do to assist.
                      JimNinjaTrader Customer Service

                      Comment


                        #12
                        Thanks Jim

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Arkadiy_B, Today, 06:43 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post Arkadiy_B  
                        Started by leontancfa, Today, 06:09 AM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_PatrickG  
                        Started by soulfx, 12-01-2017, 08:44 AM
                        3 responses
                        1,019 views
                        0 likes
                        Last Post NinjaTrader_EricB  
                        Started by Parmenides48, 04-09-2019, 03:32 AM
                        10 responses
                        53 views
                        0 likes
                        Last Post NinjaTrader_PatrickG  
                        Started by NinjaCustomer, Today, 01:48 AM
                        1 response
                        13 views
                        0 likes
                        Last Post NinjaTrader_EricB  
                        Working...
                        X