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

Total Net Profit != Cumulative Profit?

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

    Total Net Profit != Cumulative Profit?

    I was trying to keep track of my profits during backtesting, however when I check my the Total Net Profit in the Strategy Analyzer Summary, it is not the same value as the Cumulative Profit which I printed using
    Print(
    "Cum Profit:" +Performance.AllTrades.TradesPerformance.Currency. CumProfit);
    Why is that so?

    #2
    Please ensure you are printing it at the correct time and that you have Strategy Analyzer set to currency.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      How do I set the Strategy Analyzer to currency? I put the print code on the first line of OnBarUpdate(), would that be a problem? I only check that the final values are different. Therefore shouldn't be a problem of printing at the wrong timing?

      Comment


        #4
        tjendra,

        You may be missing the final Exit on Close order as the backtest finishes and closes out any remaining position at that point in time. I suggest you print out Position.MarketPosition to confirm/deny this. If your final CumProfit print is from an active long/short position then you know you are missing that final closing trade in your stats.

        You can change the presentation method of the Strategy Analyzer in the top toolbar. There should be a drop down menu where you can select Currency.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          My final market position is Long. How do I make it flat so the calculation is correct?

          Comment


            #6
            tjendra,

            You would not be able to unless you tell it to place an explicit exit before close. Whatever logic you use to place this exit will not necessarily be an exit you would like in your strategy code though.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Hello Josh, I used Print("Average cumulative profit of all trades is: " + Performance.AllTrades.TradesPerformance.Currency.C umProfit); but it prints nothing even if there is already a trade in the Account Performance Tab. The value is always zero. I don't understand why. I am using a market replay to test my strategies. I already set the accounts to replay and correct chart, templates and the providers. When I generate it, it does many trades but still the in the output window is zero. Please help me on this.

              Comment


                #8
                luxurious_04, are you using NinjaScript strategies that call ATM's here in your testing?

                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Yes I am using ATM templates but there is a line on the link that you give that says " Accessing all the trade data is still possible, but the set of commands to use differ from the traditional NinjaScript commands.". Now, if it still possible to access all the trade data then what would be other set of commands to use? Because I really want to access all the trade data as a trade filter to my strategy. Please give me tip or a sample code for it. It must be easy if I have a code just like the function of CLOSE button in the DOM. Just the code for disabling automatically the strategies running. If you can give me a tip or a HOT KEY for that one then it would be great. I hope.
                  Last edited by luxurious_04; 02-14-2011, 07:37 PM.

                  Comment


                    #10
                    luxurious_04,

                    When working with ATM strategies in NinjaScript you would want to use this subset of methods: http://www.ninjatrader.com/support/h...gy_methods.htm

                    To close out of your ATM strategy you could use this method: http://www.ninjatrader.com/support/h...ategyclose.htm

                    For a hot key to disable strategies, there is none per se, but you can setup in the Hot Key Manager under the Globals section one for "Flatten Everything" which will stop your strategies.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Flatten Everything can stop my strategies. But in the next signal it will take an order again. Is it? Anyway, please give me a sample Ninja code to automatically trigger my hot key for Flatten Everything. Thanks.

                      Comment


                        #12
                        Hello, anyone could help me on this. Is there a way that strategy can access another strategy? Like for example I have two strategies then the first one have a realized profit of 1130 and the other one have 1140. Now I want the first one to access the realize profit of the second strategy and get the sum of it. Or there a way I can get the sum of this two? I have attached a sample image.
                        Attached Files
                        Last edited by luxurious_04; 02-16-2011, 02:13 AM.

                        Comment


                          #13
                          FlattenEverything will disable your strategy, so to have it trade again, you would need to restart it first.

                          A hotkey for FlattenEverything can be setup in NT7's hotkey manager - http://www.ninjatrader.com/support/h...ey_manager.htm

                          Unfortunately NinjaScript strategies would not cross communicate, so you could not access the PnL of strategy A in strategy B - a workaround could be using txt files to 'globally' store the values for reference.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Hello Bertran, please give me a hint on how to save a value from strategy to a text file or excel and also how does strategy get or query value from a text file. By the way, is there a way to add all the value recorded in a list? How? Thank you.

                            Comment


                              #15
                              You can for example take a look at this reference sample - http://www.ninjatrader.com/support/f...ead.php?t=3477
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Barry Milan, Today, 10:35 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by WeyldFalcon, 12-10-2020, 06:48 PM
                              14 responses
                              1,428 views
                              0 likes
                              Last Post Handclap0241  
                              Started by DJ888, Yesterday, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Working...
                              X