Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimizer Pre-Conditions

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

    Optimizer Pre-Conditions

    Is there any way to enforce pre-conditions during an optimization?

    For example, say I want to optimize the period of a couple of moving averages:

    #1 SMA (2,20,1) (Fast moving average Period 2-20)
    #2 SMA (10, 50, 1) (Slow moving average Period 10-50)

    There is a range of values that overlap between the two moving averages (10-20). However I do not want to run the iterations where the fast period is greater than the slow period.

    Is there any way I can add a pre-condition; or instruct the optimizer from code to abort an interation and to skip to the next one.

    if(FastPeriod > SlowPeriod) {
    // Skip this Iteration
    }

    #2
    Hello kevinenergy,
    Thanks for your post.

    You could limit your strategies logic to only process when that condition is true or returning if it is false. Something like the following snippet at the top of your script would do the trick.

    Code:
    if (SMA(fastPeriod)[0] > SMA(slowPeriod)[0]) return;
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hey Josh, thanks for responding. I think you misunderstood my question. I'm not looking to skip strategy logic when the value of a moving average is something. I Want to make the optimizer not run an iteration when the Parameters are some value.

      Just trying to save time on an Optimization run, so that its not processing parameters I know that will not produce good results.

      Comment


        #4
        This is not something that there will be a setting for in the Optimizer. As far as I know your only option would be a workaround like what I described.
        Josh G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        85 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        47 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        29 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        32 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        67 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X