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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      65 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      149 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      99 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      286 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X