Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization function - System Quality Number

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

    Optimization function - System Quality Number

    Dear NT,

    I have been using for some tests your strategy analyzer module. Looking to the optimization part of it, I realized rapidly that it would be of very little interest. Your program proposes as optimization function the max net profit, the max av. profit, the max W/L, the min drawdown, the max profit factor……all very nice to have but totally useless from a real trading point of view.

    The only way to seriously qualify and optimize any system is through its System Quality Number (SQN). I advice you to refer to Van Tharp for reference on the subject.

    Assuming a set of N trades (N>30 for being statistically significant), SQN is defined as follow:

    SQN= Squareroot(N) * Average (of the N Profit&Loss) / Std dev (of the N Profit&Loss).

    The large the N, the more trading opportunities you have.
    The large the average P&L, the better you are obviously.
    The smaller the Std dev (P&L), the more regular are your results and the smaller are the drawdowns.

    Note here that if you optimize for the largest SQN, you maximize in fact the product N*average P&L and you minimize the Std dev (P&L) and the drawdowns at the same time.

    This is exactly what all good traders should be looking for their system.

    Since it is so simple to program, I believe that it could be rapidly integrated in NT.

    Thanks in advance.

    Best regards

    #2
    Thanks for your suggestion. We'll add it to the list.

    Comment


      #3
      Ragingbull:

      Although it's not documented, you can in fact write your own optimization types. I've done this a couple of times for the reasons you are describing -- the base ones aren't quite adequate. If you give me a little more information, maybe an example, I'll see if I can create one. It will be dependent on the required data being available in the stock data model, which it sounds like it is.

      Comment


        #4
        Actually, assuming that the avg. P&L are in points, and not percentage, try this. If not, please let me know and I'll make the changes.

        To use:

        1. Copy this to My Documents/Ninja Trader 6.5/bin/Custom/Type
        2. Recompile any of your indicators or strategies -- this will cause SQN to be compiled as well
        3. "my system quality number" will show up in your list
        4. The SQN value shows up in the Performance column on the grid

        It's a bit more computation-intensive than the standard optimizations, but not much.

        I only tested this on 6.5 beta 4, I have no idea if it works on 6.0. Also, I would expect that since I am using an interface that's not officially documented by NT, it may break from release to release.
        Last edited by Pete S; 12-14-2007, 07:29 AM. Reason: Delete old version of file.

        Comment


          #5
          Very clever.

          However, it doesn't work for 6.5. I've attached the error. I'm not suggesting you fix it, this is just FYI.
          Attached Files

          Comment


            #6
            Hi Pete,

            Thanks for the file but it does not seem to work for me either. None of my strategies are working with this new file.

            I am running on the 6.0 regular version. Is this the problem?

            Concerning the computation of the average P&L, using the values in points is OK. Using values in currency or in % can also be done but should be coherent for both the average and the std dev computations.

            Although I would suggest that you use "net P&L" values for the calculation of the average and the std dev since some scalping method can lead to very large N and therefore also to very large commission costs.

            I hope you can find out what is the problem, it would be very nice if we could have this tool working.

            Best regards.
            Last edited by Ragingbull; 12-02-2007, 06:49 AM.

            Comment


              #7
              KBJ -- that is bizarre, first, because I have been running with this for the past day on 6.5 beta 4, and second because that field comes directly from NT's standard code. Are you sure you didn't mean 6.0? Take a look inside bin/Custom/Type/@MaxNetProfit.cs and tell me if the line of code they use for that standard calculation matches what is in my file.

              Ragingbull -- why not install the 6.5 beta? I'd rather not reinstall 6.0 at this point. Are you running live? Also -- I believe that the calculation I am using does take into consideration commission costs as long as you have that value turned on when you run the strategy. Again, I am using the same calculation for net profit that NT uses in their code and it respects commission costs.

              Comment


                #8
                Oh, and KBJ, I forgot to thank you for the file handling code you posted in one of my earlier threads, that came in handy when I debugged my custom optimizer class.

                Comment


                  #9
                  As I suspected, KBJ, I think you meant 6.0. Because I can't stand leaving the impression that I put bad code out there, I attempted to run this on 6.0. It was a one line change, they've changed the net profit calculation for 6.5. Everything else appears to work ok, but I did not do intensive testing on 6.0.
                  Attached Files
                  Last edited by Pete S; 12-14-2007, 07:28 AM. Reason: Delete old version of file.

                  Comment


                    #10
                    Big ooooops .... you're right; I meant 6.0.1000.6, and I still think its clever.

                    Comment


                      #11
                      Hi pete,

                      Thanks for the effort for the new file. I have installed it and its perfectly running on my 6.0. I will make some tests.

                      You suggest that I should install the 6.5 beta 4 version. Is it up and running for day trading? Where can I find it (I have a lifetime license for 6.0)?

                      Best regards,

                      Comment


                        #12
                        Thanks for your original post -- I think this will be useful for me as well.

                        Forget my comment about the beta for now, that was just me trying to avoid recoding the file for 6.0, which I ended up doing anyway (and was trivial).

                        BTW -- if you notice any bugs with the algorithm in your testing please let me know so I can fix them.

                        Comment


                          #13
                          Hi Pete,

                          I made some test yesterday and have noticed that the SQN number that we read in the column "Performance" do not correspond to the SQN calculated manually from all trades.

                          Basically, when an optimisation sequence was completed, I have

                          Comment


                            #14
                            Hi Pete,

                            I made some tests yesterday and noticed that the SQN numbers that we read in the column "Performance" do not correspond to the SQN calculated "manually" from the trades.

                            Basically, when an optimisation sequence was completed, I have extracted the trades and calculated in Excel the corresponding SQN. It never compaired with the ones produce by the program. The program seems to produce SQN systematically too large.

                            Not being aware of how to program in C#, I can't help you much more than that.

                            I hope you can find where is the catch...

                            Note that the order of magnitude for SQN, for a very average system, is between 1 and 2.

                            Best regards,
                            Last edited by Ragingbull; 12-03-2007, 02:48 PM.

                            Comment


                              #15
                              What are you using in excel? Your own formula? If so, can you post it here?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              40 views
                              0 likes
                              Last Post alifarahani  
                              Started by Waxavi, Today, 02:10 AM
                              1 response
                              19 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Working...
                              X