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:



                            Whitmark
                            whitmark
                            NinjaTrader Ecosystem Vendor - Whitmark Development

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by DanielSanMartin, Yesterday, 02:37 PM
                            2 responses
                            12 views
                            0 likes
                            Last Post DanielSanMartin  
                            Started by DJ888, 04-16-2024, 06:09 PM
                            4 responses
                            12 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by terofs, Today, 04:18 PM
                            0 responses
                            11 views
                            0 likes
                            Last Post terofs
                            by terofs
                             
                            Started by nandhumca, Today, 03:41 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post nandhumca  
                            Started by The_Sec, Today, 03:37 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post The_Sec
                            by The_Sec
                             
                            Working...
                            X