Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Make string Ninjascript Property Optimizable

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

    Make string Ninjascript Property Optimizable

    I have the following code below :

    Code:
    [NinjaScriptProperty]
            [TypeConverter(typeof(StrategyStringConverter))] // Converts the found ATM template file names to string values
            [PropertyEditor("NinjaTrader.Gui.Tools.StringStandardValuesEditorKey")] // Create the combo box on the property grid
            [Display(ResourceType = typeof(Custom.Resource), Name = "Add Signal", GroupName = "Entries 1", Order = 0)]
            public string Signal1
            { get; set; }​
    This creates a list of strings selectable but I cannot optimize it. When I select the Optimize Backtest type, it doesn't let me try a range.

    #2
    Hello JakeOfSpades,

    Thank you for your inquiry.

    Are you using an enum to create a list of selectable strings in the Optimizer?

    Please see the sample script linked below, which demonstrates using TypeConverter and using an enum. These values are selectable in the Optimizer.

    https://ninjatrader.com/support/help...r_to_custo.htm

    If you have any other questions, please let me know.

    Comment


      #3
      Originally posted by NinjaTrader_Gaby View Post
      Hello JakeOfSpades,

      Thank you for your inquiry.

      Are you using an enum to create a list of selectable strings in the Optimizer?

      Please see the sample script linked below, which demonstrates using TypeConverter and using an enum. These values are selectable in the Optimizer.

      https://ninjatrader.com/support/help...r_to_custo.htm

      If you have any other questions, please let me know.
      Can't use enums as some of the strings have spaces and special symbols. Any ways to optimize a list of strings?

      Comment


        #4
        Hello,

        Unfortunately no, there is no way to optimize a list of strings.

        A custom type converter is needed, which will not function in the strategy analyzer.

        A TypeConverter used on an input in a NinjaScript Strategy will be disabled when the strategy is selected in the Strategy Analyzer.

        While the strategy can still be backtested or optimized, the TypeConverter behavior, such as hiding or disabling inputs will not have effect on any public variables using the [NinjaScriptProperty] attribute.

        This is due a limitation with the property grid and how the analyzer displays the [NinjaScriptProperty] marked properties of the strategy.

        A suggested work around, is to add an extra bool property for the purpose of controlling if other properties are used within the logic of the script.

        This property would not be optimized and would have the single purpose of controlling the use of the properties.

        Comment


          #5
          Originally posted by NinjaTrader_Gaby View Post
          Hello,

          Unfortunately no, there is no way to optimize a list of strings.

          A custom type converter is needed, which will not function in the strategy analyzer.

          A TypeConverter used on an input in a NinjaScript Strategy will be disabled when the strategy is selected in the Strategy Analyzer.

          While the strategy can still be backtested or optimized, the TypeConverter behavior, such as hiding or disabling inputs will not have effect on any public variables using the [NinjaScriptProperty] attribute.

          This is due a limitation with the property grid and how the analyzer displays the [NinjaScriptProperty] marked properties of the strategy.

          A suggested work around, is to add an extra bool property for the purpose of controlling if other properties are used within the logic of the script.

          This property would not be optimized and would have the single purpose of controlling the use of the properties.
          I figured it out, I had to use enums and the Display Name Attribute for my custom text. Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          51 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          129 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X