Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Optimizer access to a Strategy's public variables

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

    Optimizer access to a Strategy's public variables

    Hi NT,

    Is there a way for the Optimizer class to reference a Strategy's public variable?

    For example, within optimizer:

    // Assuming Strategies is a collection or list of the strategy instances
    // that optimizer iterates through when running an optimization

    Strategies[i].aPublicVariable = 5;

    For example, within optimizer:

    public class SomeClass: Strategy{

    public int aPublicVariable = 0;
    }

    So, when my custom Optimizer is run it will set the value of aPublicVariable to 5 for every instance of SomeClass.

    BigSurf

    #2
    Hello BigSurf,

    Yes, when the optimization is run, the strategy instance will be Strategies[0].

    This will have a collection of each property called OptimizationParameters.

    You can change each the value of each of the these if you would like.

    Strategies[0].OptimizationParameters[0].Value = 100;

    This would set the first parameter to 100.

    Below is a publicly available link to the help guide.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,

      What I mean is is there a way for me to access the instance of the Strategy's public properties and methods --- not the Strategy parameters.

      For example,

      public class SomeStrategy: Strategy{

      public AClass aClass;
      public int aValue;

      ....

      }

      Within the Optimizer class,

      How can I access aClass and aValue ?

      Mark

      Comment


        #4
        Hello Mark,

        I am not aware of a way to access the strategy instances.

        I am only aware of being able to set the values of the parameters.

        Please let me know if you would like to submit a feature request for the Strategy instance object to be provided to an Optimizer script.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Yes, please submit this.

          This is very important.

          For example, if all optimization instances share common data that is obtained from an external database (i.e. SQL Server) in that it can cut the number of back/forth from the DB substantially and significantly improve the time it takes to run a complex series of optimizations.

          BigSurf

          Comment


            #6
            Hello BigSurf,

            Calling information from an SQL database would be far outside of what is supported by NinjaTrader Support.

            However, I will submit a feature request on your behalf to make the strategy instance available to Optimizer scripts.

            Once I have a tracking ID for this request I will post this in this thread for future reference.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,602 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X