Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Performance.AllTrades Bug - Stocks

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

    Performance.AllTrades Bug - Stocks

    Hey,

    I think I've found a bug. I am running a strategy and basically printing the data from Performance.AllTrades. The percent value matches that of the Strategy Analyzer tab, but the currency and point values don't. Everything else seems to be in place (quantity, etc.)

    Any ideas? My strategy uses daily stock data.

    Thanks,
    Phil

    #2
    Phil, which stock and connection are you using to test?

    Is this on B20 or the just released B21?

    Can you please share the code you print for comparions so we could check into?

    Thanks for reporting in.

    Comment


      #3
      Hey Bertrand,

      I am using 7.20. My strategy contains the stocks in the SP500. The code for the printout is as follows:

      Code:
                  
                  TradeCollection trades = Performance.AllTrades;
                  double[] data = new double[trades.Count];
                  Print(Performance.AllTrades[0].ProfitCurrency);
                  int i = 0;
                  foreach (Trade p in trades)
                  {               
                      
                      Print(string.Format("Number: {0}\tProfit: {1}\tPercent: {2}\tQuantity: {3}\tPoints: {4}",p.TradeNumber, p.ProfitCurrency,p.ProfitPercent, p.Quantity,p.ProfitPoints));
                      data[i] = p.ProfitCurrency;
                      i++;
                  }
      This gets executed OnTermination. The percent values are fine, but currency and point values are off.

      Comment


        #4
        Can you please clarify what you mean by "off"? What values are you expecting and why? What are you seeing instead?
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          This is my output window printout:
          Code:
          ############################ TRADE STATISTICS #####################################
          -2.57
          Number: 0    Profit: -2.57    Percent: -0.120941176470588    Quantity: 472    Points: -2.57
          Number: 1    Profit: -0.23    Percent: -0.0425925925925926    Quantity: 1851    Points: -0.23
          Number: 2    Profit: 0.0300000000000007    Percent: 0.00152671755725194    Quantity: 506    Points: 0.0300000000000007
          Number: 3    Profit: 4.67    Percent: 0.0854841662090426    Quantity: 182    Points: 4.67
          Number: 4    Profit: 0.0399999999999952    Percent: 0.00068143100511065    Quantity: 168    Points: 0.0399999999999952
          Number: 5    Profit: 1.04    Percent: 0.0868838763575605    Quantity: 829    Points: 1.04
          Number: 6    Profit: -0.0300000000000016    Percent: -0.00111069974083678    Quantity: 368    Points: -0.0300000000000016
          Number: 7    Profit: 0.370000000000001    Percent: 0.0193818753273966    Quantity: 522    Points: 0.370000000000001
          Number: 8    Profit: 0.490000000000002    Percent: 0.0162736632348058    Quantity: 330    Points: 0.490000000000002
          Number: 9    Profit: 1.03    Percent: 0.0294791070406412    Quantity: 283    Points: 1.03
          Number: 10    Profit: 0.34    Percent: 0.0445609436435125    Quantity: 1305    Points: 0.34
          Number: 11    Profit: 0.650000000000002    Percent: 0.0190281030444965    Quantity: 292    Points: 0.650000000000002
          Number: 12    Profit: -0.010000000000002    Percent: -0.000228728270814318    Quantity: 227    Points: -0.010000000000002
          Number: 13    Profit: 1.81    Percent: 0.0684310018903592    Quantity: 379    Points: 1.81
          Number: 14    Profit: 0.679999999999999    Percent: 0.0257380772142316    Quantity: 377    Points: 0.679999999999999
          Number: 15    Profit: -0.18    Percent: -0.00784313725490197    Quantity: 447    Points: -0.18
          Number: 16    Profit: 0.469999999999998    Percent: 0.0189210950080515    Quantity: 402    Points: 0.469999999999998
          Number: 17    Profit: 1.25    Percent: 0.0676773145641581    Quantity: 541    Points: 1.25
          Number: 18    Profit: 1.64    Percent: 0.0418367346938775    Quantity: 253    Points: 1.64
          Number: 19    Profit: 4.37    Percent: 0.0750085822176451    Quantity: 170    Points: 4.37
          Number: 20    Profit: 0.680000000000001    Percent: 0.051243406179352    Quantity: 754    Points: 0.680000000000001
          Number: 21    Profit: 1.46    Percent: 0.0476501305483028    Quantity: 324    Points: 1.46
          Number: 22    Profit: 7.04    Percent: 0.114863762440855    Quantity: 161    Points: 7.04
          Compare this to the Strategy Analyzer Trades tab:
          Code:
                      Trade-#   Instrument   Account   Strategy   Market pos.   Quantity   Entry price   Exit price   Entry time   Exit time   Entry name   Exit name   Profit       1   SEE   Backtest   MomentumBetaNeutral   Long   472   21.25   18.7   7/24/2009   8/4/2009   Enter Long Best 13   Exit Long Best 13   -1213.04       2   LSI   Backtest   MomentumBetaNeutral   Long   1851   5.4   5.19   7/24/2009   8/4/2009   Enter Long Best 2   Exit Long Best 2   -425.73       3   NVLS   Backtest   MomentumBetaNeutral   Long   506   19.65   19.7   7/24/2009   8/4/2009   Enter Long Best 41   Exit Long Best 41   15.18       4   MTB   Backtest   MomentumBetaNeutral   Long   182   54.63   59.32   7/24/2009   8/4/2009   Enter Long Best 107   Exit Long Best 107   849.94       5   UNP   Backtest   MomentumBetaNeutral   Long   168   58.7   58.76   7/24/2009   8/4/2009   Enter Long Best 61   Exit Long Best 61   6.72       6   AES   Backtest   MomentumBetaNeutral   Long   829   11.97   13.03   7/24/2009   8/4/2009   Enter Long Best 255   Exit Long Best 255   862.16       7   LLTC   Backtest   MomentumBetaNeutral   Long   368   27.01   27   7/24/2009   8/4/2009   Enter Long Best 359   Exit Long Best 359   -11.04       8   INTC   Backtest   MomentumBetaNeutral   Long   522   19.09   19.48   7/24/2009   8/4/2009   Enter Long Best 232   Exit Long Best 232   193.14       9   WDC   Backtest   MomentumBetaNeutral   Long   330   30.11   30.62   7/24/2009   8/4/2009   Enter Long Best 439   Exit Long Best 439   161.7       10   COG   Backtest   MomentumBetaNeutral   Long   283   34.94   35.99   7/24/2009   8/4/2009   Enter Long Best 419   Exit Long Best 419   291.49       11   TER   Backtest   MomentumBetaNeutral   Long   1305   7.63   7.99   7/24/2009   8/4/2009   Enter Long Best 243   Exit Long Best 243   443.7       12   BBBY   Backtest   MomentumBetaNeutral   Long   292   34.16   34.83   7/24/2009   8/4/2009   Enter Long Best 121   Exit Long Best 121   189.8       13   NSC   Backtest   MomentumBetaNeutral   Long   227   43.72   43.73   7/24/2009   8/4/2009   Enter Long Best 157   Exit Long Best 157   -2.27       14   LM   Backtest   MomentumBetaNeutral   Long   379   26.45   28.28   7/24/2009   8/4/2009   Enter Long Best 288   Exit Long Best 288   685.99       15   MCHP   Backtest   MomentumBetaNeutral   Long   377   26.42   27.12   7/24/2009   8/4/2009   Enter Long Best 218   Exit Long Best 218   256.36       16   NTAP   Backtest   MomentumBetaNeutral   Long   447   22.95   22.79   7/24/2009   8/4/2009   Enter Long Best 190   Exit Long Best 190   -80.46       17   PTV   Backtest   MomentumBetaNeutral   Long   402   24.84   25.33   7/24/2009   8/4/2009   Enter Long Best 377   Exit Long Best 377   188.94       18   MWV   Backtest   MomentumBetaNeutral   Long   541   18.47   19.74   7/24/2009   8/4/2009   Enter Long Best 87   Exit Long Best 87   676.25       19   CSX   Backtest   MomentumBetaNeutral   Long   253   39.2   40.86   7/24/2009   8/4/2009   Enter Long Best 84   Exit Long Best 84   414.92       20   FCX   Backtest   MomentumBetaNeutral   Long   170   58.26   62.65   7/24/2009   8/4/2009   Enter Long Best 444   Exit Long Best 444   742.9       21   AMAT   Backtest   MomentumBetaNeutral   Long   754   13.27   13.97   7/24/2009   8/4/2009   Enter Long Best 98   Exit Long Best 98   512.72       22   KLAC   Backtest   MomentumBetaNeutral   Long   324   30.64   32.12   7/24/2009   8/4/2009   Enter Long Best 384   Exit Long Best 384   473.04
          The data such as quantity seems fine - but not the PnL in Currency terms (or points for that matter). However, strangely enough, the percentage returns are ok...

          Comment


            #6
            Actually see this attachment - the last post turned out sloppy. The second tab on the excel sheet is my output window.

            Cheers,
            Phil

            (Couldn't attach the excel file - here is a dl link: http://dl.dropbox.com/u/4609610/NT%20bug.xlsx )

            Comment


              #7
              Phil, I compared some values and it looks to me like you're running into rounding issues here, which could be larger then expected if percent % is cumulated through the testing.

              Comment


                #8
                Ok well what should I do...I am not manipulating the numbers/calculating myself. I am just accessing Performance.AllTrades[i].ProfitCurrency. Is this then a NT bug?

                Comment


                  #9
                  Phil, you could round the output window as needed to align the results - you can't compare the 'raw' doubles with the Excel sheet.

                  Comment


                    #10
                    But they are no where near...profits should be a few hundred dollars give or take whereas output window shows very small numbers...They are not even in the same scale.

                    Comment


                      #11
                      pmorissette,

                      That is because you are simply printing ProfitCurrency. ProfitCurrency is the profit of one traded unit. If you want profit currency of the whole trade you need to multiply this number by the trade quantity. http://www.ninjatrader.com/support/h.../nt7/trade.htm
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        I see! Sorry about that. Should have read the help files first.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        581 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        338 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        103 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        554 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        552 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X