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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        144 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        71 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        125 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        79 views
        0 likes
        Last Post PaulMohn  
        Working...
        X