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 NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 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