Announcement

Collapse
No announcement yet.

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 NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            54 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            131 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X