Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScriptProperty preset of boolean variable

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

    NinjaScriptProperty preset of boolean variable

    Hello,

    I would like to use properties in a strategy. When using a variable with type bool, I want to preset it with true. Using integer this can be done with range. How can I do that with a boolean type? Here an example:

    [NinjaScriptProperty]
    [Display(Name = "UseMovingAverage", GroupName = "Parameters", Order = 1)]
    public bool UseMovingAverage{ get; set; }

    How can I initialize the variable with UseMovingAverage=true when inserting the strategy?

    Kind regards
    Gerik

    #2
    Hello Gerik,

    Thank you for your inquiry.

    You would set the default value of your bool input in State.SetDefaults.

    In State.SetDefaults:

    Code:
    MyBool                    = true;
    In the Properties region:

    [NinjaScriptProperty]
    [Display(Name="MyBool", Order=1, GroupName="Parameters")]
    public bool MyBool
    { get; set; }

    Please let us know if you have any further questions.

    Comment


      #3
      Thank you Gaby! :-)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X