Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

user defined parameters with upper and lower limit

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

    user defined parameters with upper and lower limit

    Ho do I define a parameter in the properties section that will allow me to set a lower and an upper limit to the value that is acceptable?

    the code below returns a value of 2 only, but I want it to be 1 or 2.

    publicint Var1{
    get { return var1; }
    set { var1 = Math.Max(1, 2); }
    }

    Thanks!

    #2
    malcolm, would unfortunately not be aware of a way, I would just limit one range in the properties and the other for example in OnBarUpdate()...if (Var1 > x) Var = x

    Comment


      #3
      Malcom,

      Try

      public int Var1
      {
      get { return var1; }
      set { var1 = Math.Min(Math.Max(1, value), 2); }
      }

      Greg
      Last edited by TheTradingMantis; 02-19-2011, 12:54 PM.
      The Trading Mantis
      NinjaTrader Ecosystem Vendor - The Trading Mantis

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, Yesterday, 01:02 PM
      0 responses
      29 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      21 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      160 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      95 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      148 views
      2 likes
      Last Post CaptainJack  
      Working...
      X