Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom optimizer questions

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

    Custom optimizer questions

    Hi all,

    I'm trying to get a custom optimizer running, and have run into an issue whereby it seems that NinaTrader won't allow an optimizer to set values for enum or bool strategy parameters (perhaps other types too; so far only double and int have worked).

    For such parameters, Parameter.ParameterType returns the correct .NET type, but trying to set Parameter.Value to an instance of that type causes an exception for Enum parameters while having no effect for bool parameters.

    I tried setting bool parameters to 0/1 and enum parameters to (int)enumValue to see if NT would internally convert them, but that didn't help either - the values were just ignored.

    How can the optimizer set strategy parameters of these types?

    Also, what is the recommended way to pass the output of a fitness function back to the optimizer? A static member variable is a hack at best.


    Thanks,

    Swig.

    #2
    Swig,

    Unfortunately creating custom optimizers is not supported. As far as optimizing, you can optimize on doubles and ints where you can pass in the start and end values as well as the increment. You can't really set up these requirements for an enum.

    Not sure what you mean by passing back a fitness function. Each optimizer run is independent of each other.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Thanks. I already have the optimizer working (loosely based on Pete S.'s genetic optimizer), but it sounds like I have to stick to doubles and ints in the strategies.

      I hope NT7 will support these parameter types - since bools and enums can be converted to a number, I think you can come up with meaningful 'min/max' (maybe 'start/end' is more suitable) values. Or use the full range implied by the type.

      As for the fitness function, sorry I didn't explain very clearly. The optimizer uses a genetic algorithm, and as such I'd like to obtain the output of the 'Optimize on' function (i.e. fitness function) for each iteration within the optimizer so that I can use it to select candidates for reproducing.

      Pete S. used a static member in his fitness function that the optimizer accessed, but that's a bit ugly. I'm wondering if there is a way to access it via an NT property/method call immediately after the optimizer calls Strategy.RunIteration().


      Cheers,

      Swig.

      Comment


        #4
        Thank you for the suggestions.

        Unfortunately there is no NT method/property supported for what you want.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          Thank you for the suggestions.

          Unfortunately there is no NT method/property supported for what you want.
          Can I request that you update the strategy's "Performance" property before returning from RunIteration()? or provide another way to access this from within the optimizer?

          i appreciate that custom optimizers aren't "supported", but this simple change would eliminate the one place where an ugly hack is required to implement them.
          Last edited by piersh; 09-03-2009, 10:42 AM.

          Comment


            #6
            Sorry piersh, I am not sure what you mean. Can you provide some context? Thank you.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              Sorry piersh, I am not sure what you mean. Can you provide some context? Thank you.
              sure, in an OptimizationMethod's Optimize() method, unless the method is naive (like the built-in one), you need to be able to compare the result of different calls to RunIteration().

              Before RunIteration() returns, it calls OptimizationType.GetPerformanceValue() passing the SystemPerformance value that is the results of the backtest run. it is the value that GetPerformanceValue() returns that needs to be compared.

              it seems like there is no way, from within the Optimize() method to access either this SystemPerformance, or the result of GetPerformanceValue().

              here are some solutions to this:

              - make RunIteration() return the SystemPerformance that results from the backtest
              - make RunIteration() return the double returned from GetPerformanceValue()
              - update the strategy's Performance & PerformanceValue properties to reflect the results of the backtest.
              - add LastPerformance/LastPerformanceValue properties to OptimizationMethod

              does that make sense?

              Comment


                #8
                I see. Unfortunately this is unsupported.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  I see. Unfortunately this is unsupported.
                  yeah, i'm painfully aware of that.

                  just asking if you can 'unofficially' remove this roadblock to massively increasing the usefulness of your product.

                  if i were you, i'd be jumping at the chance to allow 3rd parties to improve my product for free!

                  just saying...

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Aviram Y, Today, 05:29 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post Aviram Y  
                  Started by quantismo, 04-17-2024, 05:13 PM
                  3 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by ScottWalsh, 04-16-2024, 04:29 PM
                  7 responses
                  34 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by cls71, Today, 04:45 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post cls71
                  by cls71
                   
                  Started by mjairg, 07-20-2023, 11:57 PM
                  3 responses
                  216 views
                  1 like
                  Last Post PaulMohn  
                  Working...
                  X