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

Standard backtest vs. Market replay data & playback

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

    Standard backtest vs. Market replay data & playback

    I created a strategy which when tested in the Strategy Analyzer appears profitable. See image 01, blue circle shows the dates of backtest, green circles shows the expected profitability. Image 02 shows the results produced by using Market Replay Playback. The blue circle shows the dates, the red circles show the lack of profitability.

    Both tests ran the same strategy with exactly the same settings.

    Image 03 shows the trades produced by each method. The green circles highlight the similarity of the trades taken by both strategies. The red circles highlight differences in profitability and entry/exit times. It is interesting to note how the entry/exit times are offset by 30 minutes but otherwise track together for the highlighted trades.

    What can account for the differences seen in theses results?

    Thanks
    Ken
    Attached Files

    #2
    Hello,

    Thank you for your note.

    The reason for this is your barstype, heiken ashi. If you compare that bar type to a 1 minute candle, you’ll see that that bars type is not an accurate reflection of price action, but rather modified for visual purposes. For example you’ll notice certain times when the open of heiken ashi bar type is always below the close of the previous bar on an up move, giving you instant profits in a backtest. Running on replay is going to give you the most accurate returns.

    To resolve this in the backtest I suggest you add a 1 tick series,
    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi Alan,

      Thanks for the reply and particularly the url. I am using the Strategy Builder to create my strategies. Is this suggestion different from setting the strategies Calculate mode to On Each Tick?

      Looking at my options when defining EnterLong, I don't appear able to specify an alternate bar series. So while I can create an additional bar series with ticks, I don't see how to reference that when setting up the EnterLong action in my strategy.

      Also in the example downloaded from the url, for the secondary series, the bar period type was defined as 'tick'. The comments refer to this as if it where a 1minute bar series. Is that correct?
      Last edited by cupir2; 10-14-2018, 10:25 PM.

      Comment


        #4
        Hello cupir2,

        First, you'll need to unlock the code and manually edit the EnterLong order to make it look like this:
        Code:
        EnterLong(1, 1, "ordername");
        The sequence is explained as follows.
        Code:
        EnterLong(int barsInProgressIndex, int quantity, string signalName)
        We choose 1 for barsInProgressIndex to execute off the secondary data series.

        Second, the secondary series is set at 1 tick to get the most accurate execution. 1tick is faster than 1min. It seems to me that the 1 min reference was only used to explain the sequential order of logic under OnBarUpdate.

        Comment


          #5
          I have been using Calculate set to "On Bar Close" within the strategies Default Properties? Can I still use that or must I now use "On Each Tick"?
          Thanks

          Comment


            #6
            When the Strategy or Indicator are set to Calculate On Bar Close, it means that the logic or conditions will be run once on the close of each bar. When it's set On Each Tick, then it runs the conditions once every tick.

            This is not the reason for the disparity between playback and strategy analyzer. The reason for this disparity is the way Historical Processing works; explained here = https://ninjatrader.com/support/help...on_builder.htm

            When you link your order to execution off a 1 tick series, then Historical Processing becomes more accurate. But I would still recommend you always double check your testing on Playback since it is the most accurate.

            Comment


              #7
              Hello cupir2,

              Kingkoda explains it well, thank you.

              Yes, this would be different than running on each tick. This you would be adding an additional data tick series so that you submit orders to that series rather than the custom bar series.
              This would be slightly more advanced than the strategy builder and would require unlocking the code and adding the additional data series, but if you were to unlock your code and compare the text vs the sample I provided, you should be able to figure it out.

              If you would like someone to reach out with a list of third parties I can have someone pass on a list.

              Please let us know if you need further assistance.

              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Hi,

                Thanks to both of you, this has been very helpful. While I am not a programmer this makes enough sense that I can easily make those changes. I would be interested in a list third parties that could provide coding help and possibly tutoring.

                Thanks again.

                Comment


                  #9
                  Hello Cupir,

                  This is Jared from the NinjaTrader Business Development team responding on behalf of my colleague Alan.

                  You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more:

                  Search trading indicators, apps and services to personalize your NinjaTrader software. Explore custom trading indicators, automated strategies, free trading apps & more!


                  You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third-party services for NinjaTrader, all pricing and support information will need to be obtained through the consultant.

                  Let me know if I may be of further assistance

                  This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem, LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                  Jared M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by MarianApalaghiei, Today, 10:49 PM
                  2 responses
                  8 views
                  0 likes
                  Last Post MarianApalaghiei  
                  Started by love2code2trade, Yesterday, 01:45 PM
                  4 responses
                  28 views
                  0 likes
                  Last Post love2code2trade  
                  Started by funk10101, Today, 09:43 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post funk10101  
                  Started by pkefal, 04-11-2024, 07:39 AM
                  11 responses
                  37 views
                  0 likes
                  Last Post jeronymite  
                  Started by bill2023, Yesterday, 08:51 AM
                  8 responses
                  46 views
                  0 likes
                  Last Post bill2023  
                  Working...
                  X