Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

New Optimizer Type: System Quality Number

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

    New Optimizer Type: System Quality Number

    Updated: please download SQN.cs (for NT version 6.5) from the Genetic Optimizer thread in this forum. I don't want to maintain the file in 2 places and it is required for that optimizer as well. Thanks.

    This is a new optimizer type for comparing strategies in the Strategy Analyzer called System Quality Number. The formula is

    SQN = sqrt(N) * average("Profit") / stddev("Profit")

    where N is the number of trades, which encourages a large number of trades, a large average profit, and a small standard deviation. You can read more about Ragingbull's description of this number in the original thread that I coded the optimizer from here: http://www.ninjatrader-support.com/v...ead.php?t=4320

    To install, take SQN6 if you are running 6.0, or SQN if you are running 6.5.

    1. Copy this to My Documents/Ninja Trader 6[.5]/bin/Custom/Type
    2. Recompile any of your indicators or strategies -- this will cause the optimizer type to be compiled as well
    3. "my system quality number" will show up in your list of optimizer types
    4. The SQN value shows up in the Performance column on the grid (see attached screenshot)

    Keep in mind that as far as I know, this type of customization is not supported by NT, so if anything goes wrong, a reinstall may be your only recourse. Having said that, I have not had any issues thus far.

    Feel free to post issues in this thread and I will try to help.
    Attached Files
    Last edited by Pete S; 02-12-2008, 06:47 AM. Reason: Moved SQN.cs to Genetic Optimizer thread

    #2
    Thanks very much for your work and to Raging Bull aswell.
    You brought us a nice tool here!
    Last edited by ryker; 12-13-2007, 12:31 PM.

    Comment


      #3
      Originally posted by ryker View Post
      You brought us a nice tool here!
      AND, a window into just how other fitness functions could be created.

      Thanks.

      dwt

      Comment


        #4
        Static class variable

        Hi,

        I noticed the following 2 declaration in the SQN source file:

        public class SQN : OptimizationType
        {
        public static double sLastSQN;
        public static int sMinTrades = 0;


        This 2 variables are declared static. If you should ever create more than one instance of this class, then these variables are shared across all class instances. I am not sure this is intended behaviour, especially for sLastSQN.

        Regards
        Ralph

        Comment


          #5
          Hi,

          I'm running NT 6.5 so I need SQN.cs. I did a search but I came up empty. Can someone post a link to that file?

          Thanks,

          Comment


            #6
            Originally posted by Paul_J View Post
            Hi,

            I'm running NT 6.5 so I need SQN.cs. I did a search but I came up empty. Can someone post a link to that file?

            Thanks,

            Comment


              #7
              Error Resolution

              Hi

              I have attempted to load the update to your optimizer and
              receive this error message;

              Type\SQN6.cs NinjaTRaderStrategy TradeCp;;ectopm" does not contain
              a definition for 'performance" CS0117 Line 41 column 52

              And same error message for line 42 column 33

              Any Suggestions?

              Thanks

              Lynn

              Comment


                #8
                Originally posted by Pete S View Post
                This is a new optimizer type for comparing strategies in the Strategy Analyzer called System Quality Number. The formula is

                SQN = sqrt(N) * average("Profit") / stddev("Profit")

                where N is the number of trades, which encourages a large number of trades, a large average profit, and a small standard deviation.
                That's an interesting idea, but it penalizes you for having a few big profits in your sequence rather than steady profits. Some strategies simply aren't designed that way.

                The system quality measure I'm more familiar with (via Van Tharp), described here can be reduced to

                SQN = net_profit/average_loss

                ...where average_loss doesn't include "scratch" losses where you lose only commission and slippage. That formula also encourages maximizing both profit and quantity of trades, and minimizing losses.

                Other trading platforms let you define your own custom optimization result. I'm still fairly new to NinjaTrader; doesn't NT let you do that too?

                -Alex

                Comment


                  #9
                  I have a question on the code. When you are going through each trade, you call several methods in the Trade class:

                  Code:
                  tradeProf = (t.ProfitPoints * t.Quantity * t.Entry.Instrument.MasterInstrument.PointValue);
                  Is ProfitPoints the number of points made/lost in the trade?
                  Quantity? Is that the number of contracts/Stocks traded in that transaction?
                  How about PointValue? the value per point per contract in currency?

                  So, say I trade 1 Contract of S&P Emini, at $50/point, and make 5 points that would be:

                  tradeProf = 5 * 1 * 50 = 250

                  Is that what it is?

                  Thanks!

                  Comment


                    #10
                    I was asking about the code before because this SQN number looked familiar. I don't know who this Van Tharp guy is and I have not read his books; but I think he is claiming something that was published back in 1908. At least if he is claiming this as his discovery; but, again, I have not read his books.

                    What he calls "SQN" number, is actually the Student t statistics. You can read about it here:

                    Wiki Student T

                    I don't know, he may have been the first one to relate trading to statistics and that is why he is claiming it with that name (that is giving him the benefit of the doubt). I'm not a judge. But, definitely, it's not something "new".

                    I can say this, however, it is useful. I don't think it will "increase" the number of trades; at least not in my experience. It does optimize the number of trades though. And I can tell you also that a big "SQN" number is not necessarily good. In fact, a big "SQN" number may be a sign of over-fitting. So, be aware of that.

                    About the code, I would need to test some more; but I found it to increase rapidly after 2.5 or so and it would jump very fast. I am not sure why, I may be wrong. When I find it I will let you know.

                    Comment


                      #11
                      HI everybody

                      I've developed a futures strategy. After some optimization with the SQN, I get an SQN = 3.4 with 500 trades

                      ¿3.4.....What does it mean? ¿Dollars? ¿Points? ¿Percent..?

                      ¿Is it good or bad? ¿Is SQN a better indicator than sharpe ratio?

                      Regards

                      Comment


                        #12
                        Originally posted by magicboiz View Post
                        ¿3.4.....What does it mean? ¿Dollars? ¿Points? ¿Percent..?
                        ¿Is it good or bad? ¿Is SQN a better indicator than sharpe ratio?
                        The SQN number isn't dollars, percent, or any other normal unit. It is just a unit-less measure of risk-adjusted performance (similar to the sharpe ratio). Higher numbers are better. If you want a more tangible number, look at something like cumulated profit, average trade %, etc. If you can get a 3.4 SQN with a few dozen actual or sim trades using realtime data (not historical data subject to curve fitting), then you are in very good shape. Whether the SQN is better than sharpe ratio is for you to decide based on your preferences for risk and return. In general, I slightly prefer it, since it doesn't penalize occasional very large winning periods the way the sharpe ratio does. My other favorite performance measure is a monthly Sortino Ratio, but it is not built-into NT.

                        Comment


                          #13
                          what is a good SQN

                          I'm getting an SQN of 6.9 with about 400 trades over 3 years, is that good ?

                          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
                          6 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
                          41 views
                          0 likes
                          Last Post alifarahani  
                          Started by Waxavi, Today, 02:10 AM
                          1 response
                          21 views
                          0 likes
                          Last Post NinjaTrader_LuisH  
                          Working...
                          X