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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X