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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      667 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      377 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      110 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      580 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X