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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      167 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      88 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      128 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      208 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      185 views
      0 likes
      Last Post CarlTrading  
      Working...
      X