Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Setting Parameter to 0

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

    Setting Parameter to 0

    I am using the standard get/set on my indicator parameters. I have an "int" that I want the user to be able to set to 0. However, when I type in 0 in the parameter window, it immediately gets changes to 1.

    Any ideas?

    Thanks.

    #2
    Hello,

    Thank you for the question.

    This is caused in your public property.
    I will post an example below, you need to change the Range of the Minimum value

    Code:
    #region Properties
    
    [Description("Numbers of bars used for calculations")]
    [GridCategory("Parameters")]
    public int Period
    {
    	get { return period; }
    	[B]set { period = Math.Max(1, value); }[/B]
    }
    #endregion
    Where you see the 1, value. you would need to either change the 1 to a 0, or remove the Math.Max() and replace it with just value. The second option will allow the user to enter anything though so this may cause the script to error if you did not plan for that.

    Please let me know if i may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I set max to (0, value) and that did the trick. Perfect!

      Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Irukandji, Today, 04:58 AM
      0 responses
      2 views
      0 likes
      Last Post Irukandji  
      Started by fitspressoburnfat, Today, 04:25 AM
      0 responses
      2 views
      0 likes
      Last Post fitspressoburnfat  
      Started by Skifree, Today, 03:41 AM
      1 response
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      604 views
      0 likes
      Last Post NinjaTrader_Jason  
      Working...
      X