Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Switch statement for selecting exit condition for default optimizer

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

    Switch statement for selecting exit condition for default optimizer

    Greetings,

    In general, to get me started, do you have sample code available for the selection of certain 'if' sets of conditions, such that they can be selected during an optimizer run to see which is best suited? I think I am looking to put something in the 'variables' to allow this to work?

    ie:
    // dont know how to tag these to make them switchable for optimizer
    // this is my first condition pseudo code
    {
    if (ema20 < ema40)
    { exitlong;}
    // this is my 2nd condition pseudo code
    if (ema20 < ema60)
    { exitlong;}
    }

    When setting up the optimizer I expect I would have an option
    'useSwitchesOptionForExits'
    and then 1;2;1 to cycle through those conditions

    Thanks!
    Jon

    #2
    Hi Trader.Jon,

    I suggest using the Strategy Wizard to see how these are setup. Create a variable, then see how this is reflected in the "Variables" region of the code, as well as the "Properties" region.

    For example, if you call you int variables "Var1" and "Var2"...

    if (EMA(Var1)[0] < EMA(Var2)[0])

    Once done, you will see Var1 and Var2 available in the optimizer.
    TimNinjaTrader Customer Service

    Comment


      #3
      Branch OR Switch == which is best ??

      Tim,

      Thanks for the input.

      I am not trying to make those 'Var1' and 'Var2' the items to optimize.
      I am trying to optimize against
      if (ema20 < ema40) && ( more conditions)
      versus
      if (ema20 < ema60) && ( more other conditions)
      versus
      if (??) && ( still more conditions)
      versus
      if (??XY) && ( more varied conditions)

      So located the 'Branching Commands' in the helpF1 and need guidance on the best option for what I want to do with the optimizer, that is, selecting conditions for what is the most optimal exit condition and let the default 6.5/7 optimizer work it out. Use the 'else if' options, or the 'case' variation ??? I am guessing "//Multiple case decision" except that I have 10 options to run through and not sure if the 'else if' and 'else' and 'if' are limiting me to 3 ONLY ??

      THANKS!
      Jon
      Last edited by Trader.Jon; 07-19-2010, 02:12 PM. Reason: more info added

      Comment

      Latest Posts

      Collapse

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