Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy parameters

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

    strategy parameters

    I would like to restrict the values of a parameter of a strategy to a few distinct values say 1, 2, 4, 6

    In the set method for the parameter should I do something like the following?

    set{
    if (value==1 || value==2 || value ==4 || value==6)
    {
    myparameter = value;
    }
    else
    {

    throw new Exception("Inavlid parameter");
    }
    }

    #2
    mballagan,

    No. That just means users typing in other values will have problems. Instead you should just do it in your OnBarUpdate where if the variable is 2 you do something, if it is 4 you do something else, but if it is 3 it just does nothing.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      parameters

      Thanks but the problem with that is that the user has no message indicating that they have entered an invalid parameter.

      Comment


        #4
        Right. What you want is not supported, but you can try your idea. If it is a int parameter it will be able to take on all values unless you generate some logic that resets it to some default value that is allowed.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X