Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Genetic Optimizer v1.5

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

    #16
    Originally posted by bluelou View Post
    1) Why scale an average by sqrt(N)?
    2) Wouldn't calculating an annualized standard deviation make more sense? I.e., stdev(profit)*sqrt(N), where N = # of trades per year,
    so that "SQN" = average(profit)/(stdev(profit)*sqrt(N)).
    If you annualize the standard deviation, you have to annualize the profit too:

    SQN = N*average(profit)/(stdev(profit)*sqrt(N)) = sqrt(N)*average(profit)/stdev(profit).

    Comment


      #17
      Barbara2,
      Yes, you're right. Sorry, I forgot to include that. I guess one reason not to annualize the stdev is that you can't if N = # of trades.

      However, N*avg(profit) isn't how you annualize profit either.
      Let A = Product(1 + Nj),
      Annualized profit((1+A)^(12/N)),
      where Nj is the %return for each period and N is # of periods.

      I guess that while you wouldn't interpret sqrt(N)*stdev(profit), where N = # of trades, not periods, as a scaled stdev. But, it still stops the variance from exploding which is the point. I.e., we don't want variance(profit)*N, which is why this is calculated as sqrt(variance(profit)*N) = stdev(profit)*sqrt(N).

      My main point is still that it makes sense to scale stdev by sqrt but I'm still not getting why SQN users are scaling the mean and not the stdev.
      -Lou

      Comment


        #18
        The sharpe ratio is usually annualized without compounding.

        The sharpe ratio (without the risk free return) for a certain period is:

        Sharpe ratio per_period = average(profits_per_period)/stdev(profits_per_period) (arithmetic averages)

        The period could be per_day, per_month, per_trade, etc.

        To compare and rate the sharpe ratio from different periods, you have to scale the sharpe ratios to a common time period, usually a year.

        With N = number of periods (days, months, trades) per year, you get: (no compounding)
        - annualized average profits = N*average(profits)
        - annualized standard deviation = sqrt(N)*stdev(profits)
        - annualized sharpe ratio = N*average(profits)/(sqrt(N)*stdev(profits))
        = sqrt(N)*average(profits)/stdev(profits) = sharpe ratio per_year


        The SQN in the Genetic Optimizer is the sharpe ratio of the different systems,
        scaled from the per_trade period to the optimization_time_period:

        the sharpe ratio per_trade for each result is: average(profits_per_trade)/stdev(profits_per_trade)

        with N = trades per_optimization_time_period, the sharpe ratio per optimization_time_period is:

        sqrt(N)*average(profits_per_trade)/stdev(profits_per_trade) = sqrt(N) * sharpe ratio per_trade = SQN

        Now you can compare the optimization results:
        a system with the same sharpe ratio per_trade but more trades = higher SQN is usually preferable.
        Last edited by Barbara2; 06-26-2008, 01:30 PM.

        Comment


          #19
          Barbara2,
          I'll take your word for it that this is the reasoning behind the SQN formula. Unfortunately, this logic doesn't fit with the way Sharpe ratios are used or calculated by institutional investors (my background).

          Professionally, if I didn't scale the stdev or talked about a sharpe ratio per period it would have been bad news.

          Anyway, unless NT does it, I can't imagine free G/O code is going to be improved for different objective functions.

          Thanks,
          Lou

          Comment


            #20
            Pete,

            Giving your nifty optimizer a try here, but ran into a snag. Using version 1.5 and followed directions to copy the two provided files to the Types directory. Recompiled my strategy and then selected optimize as instructed.

            When I attempt to run, I get the following error logged:

            Failed to call method 'Optimize' for optimizer 'GAOptimizer': Unable to cast object of type 'System.Double' to type 'System.String';

            Where did I go wrong?

            Comment


              #21
              Still running into problems here with running this Optimizer. I have found that it will run on SampleMACrossover strategy, but will not run on ANY of the strategies I have written. I have combed through code to compare my strategies to this sample. The only real difference I can find is that my strategies seem to all include a "using NinjaTrader.Gui.Chart;" statement and the SampleMACrossover does not.

              Any idea why this is stumbling?

              Error message is: Failed to call method 'Optimize' for optimizer 'GAOptimizer': Unable to cast object of type 'System.Double' to type 'System.String'.

              Comment


                #22
                It is my understanding that a strategy can only have numeric parameter variables when using this optimizer so you will need to convert any strings or bool to int or double accordingly. Hope that helps.
                whitmark
                NinjaTrader Ecosystem Vendor - Whitmark Development

                Comment


                  #23
                  The link to the documentation doesn't seem to work anymore.

                  Also, does this code work with the latest version of NT?

                  Comment


                    #24
                    Hi 1011101, welcome to the NinjaTrader support forums! Please contact the author of this code directly then, you can do so with the forum 'Private Meassage' functionality, thanks!
                    BertrandNinjaTrader Customer Service

                    Comment


                      #25
                      Installation document. Genetic Optimizer

                      If somebody knows how to install Genetic optimizer, please tell me.
                      Thanks

                      Comment


                        #26
                        Please copy both cs files in the MyDocuments\NinjaTrader 6.5\bin\Custom\Type folder and then compile all your NinjaScript studies.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #27
                          Thanks

                          Thank You very much.
                          Originally posted by NinjaTrader_Bertrand View Post
                          Please copy both cs files in the MyDocuments\NinjaTrader 6.5\bin\Custom\Type folder and then compile all your NinjaScript studies.

                          Comment


                            #28
                            Genetic Optimizer 2.0 for NinjaTrader 6.5

                            A new enhanced and supported genetic optmizer is referenced in this thread:

                            http://www.ninjatrader-support2.com/...ad.php?t=17351

                            Whitmark
                            whitmark
                            NinjaTrader Ecosystem Vendor - Whitmark Development

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by yodaler, Today, 06:12 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post yodaler
                            by yodaler
                             
                            Started by op1031, Today, 05:16 PM
                            0 responses
                            1 view
                            0 likes
                            Last Post op1031
                            by op1031
                             
                            Started by fscabrera03, Today, 01:18 PM
                            1 response
                            12 views
                            0 likes
                            Last Post fscabrera03  
                            Started by BottomShark77, Today, 12:20 PM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_ShawnB  
                            Started by bowling, Today, 06:16 AM
                            3 responses
                            30 views
                            0 likes
                            Last Post NinjaTrader_ShawnB  
                            Working...
                            X