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

Mysterious inflated profit/loss value during backtest does not match chart

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

    Mysterious inflated profit/loss value during backtest does not match chart

    I'm noticing extreme profits and losses while backtesting which does not match the open/close prices shown on the chart for the simulated trade.

    The example below shows two /NQ contracts that experienced a combined -25pt loss. The same trade appears as a -100 point loss and inflates the statistics. The trade log records the appropriate open price (11351.50 and close price of 11339), resulting in a loss of -25 points. However, the 'Profit' column shows 100 points, MAE is 100 points.What in the world? Has anyone else experienced this?

    I'm using stock data, so there are no custom data errors. 5-minute calendar, standard order fill resolution. The strategy is using a 12.5pt stop loss which I'm setting in code (and which works great on the charts and in real life.

    Thanks for your help!


    ​​

    #2
    Hello st0rm,

    Welcome to the NinjaTrader forums!

    If the strategy is using Calculate.OnBarClose, you can use High Order Fill Resolution increase the accuracy of fills.
    If the strategy is using Calculate.OnEachTick or .OnPriceChange 1-tick intra-bar granularity and TickReplay is necessary for accurate fills.

    Below is a link to a forum post that discusses both.


    If you are interested in analyzing the data to understand what is causing difference between real-time and backtest, see the post below.
    Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello st0rm,

      Welcome to the NinjaTrader forums!

      If the strategy is using Calculate.OnBarClose, you can use High Order Fill Resolution increase the accuracy of fills.
      If the strategy is using Calculate.OnEachTick or .OnPriceChange 1-tick intra-bar granularity and TickReplay is necessary for accurate fills.

      Below is a link to a forum post that discusses both.
      https://ninjatrader.com/support/foru...377#post773377

      If you are interested in analyzing the data to understand what is causing a difference between real-time and backtest, see the post below.
      https://ninjatrader.com/support/foru...nce#post100192
      Thank you. I've been on quite a journey since this post but am still experiencing the same behavior. I've tried almost everything:

      - Enable tick replay, add a 1-tick series to my strategy, and place orders using the proper EnterLong(1,<qty>,<entry-name>) format.
      - Enable 'High' order fill resolution

      I've noticed the 'profit' column is showing 4x the true profit/loss in every case. (see screenshot below)

      I don't believe this is a problem with random fills, as the trades on the chart do not contain wild bars. Could there be any other cause? This is making my backtesting very difficult. Thanks.

      Click image for larger version

Name:	image.png
Views:	105
Size:	577.7 KB
ID:	1251315
      Attached Files
      Last edited by st0rm; 05-12-2023, 08:23 PM.

      Comment


        #4
        st0rm Is that -63 column the number of TICKS of profit or loss rather than points?
        Last edited by QuantKey_Bruce; 05-13-2023, 04:54 PM.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Originally posted by QuantKey_Bruce View Post
          st0rm Is that -63 column the number of TICKS of profit or oss rather than points?
          Oh my. Yes, those are TICKS! Ha! I had changed the display from Pts to Ticks without realizing it.

          Mystery solved. Thank you!

          Comment


            #6
            Glad to be of service.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #7
              Originally posted by QuantKey_Bruce View Post
              Glad to be of service.
              Very much appreciated, thank you. I'll return the favor to the community some day

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Option Whisperer, Today, 09:55 AM
              1 response
              11 views
              0 likes
              Last Post bltdavid  
              Started by port119, Today, 02:43 PM
              0 responses
              1 view
              0 likes
              Last Post port119
              by port119
               
              Started by Philippe56140, Today, 02:35 PM
              0 responses
              3 views
              0 likes
              Last Post Philippe56140  
              Started by 00nevest, Today, 02:27 PM
              0 responses
              2 views
              0 likes
              Last Post 00nevest  
              Started by Jonafare, 12-06-2012, 03:48 PM
              5 responses
              3,986 views
              0 likes
              Last Post rene69851  
              Working...
              X