Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtest Optimazation Rules?

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

    Backtest Optimazation Rules?

    If I have a strategy that has 2 parameters, lets call them A & B both can range from 1 to 100 and I want to optimize, but A must always be greater than B, is there anyway I can stop the optimizer from even trying the tests that don't fit the criteria?

    #2
    Hello drumuk,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    When setting the value you can make sure it's the max of either the other value or it's own. For example: set { greater = Math.Max(lesser, value); }

    Below is an example of how to set these properties:
    Code:
            #region Variables
    		private int greater = 20;
    		private int lesser = 10;
            #endregion
    		
            protected override void Initialize()
            {
    			
            }
    		
            protected override void OnBarUpdate()
            {
    			
            }
    		
            #region Properties
    		[Description("")]
    		[GridCategory("Parameters")]
    		public int Lesser
    		{
    			get { return lesser; }
    			set { lesser = Math.Max(1, value); }
    		}
    		[Description("")]
    		[GridCategory("Parameters")]
    		public int Greater
    		{
    			get { return greater; }
    			set { greater = Math.Max(lesser, value); }
    		}
            #endregion

    Comment


      #3
      Thanks, am I right in thinking that doesn't stop the backtest, but forces the parameters to be a valid setup?

      Comment


        #4
        Hello drumuk,

        That is correct, it would force the parameters to be correct when starting the strategy.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        111 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        60 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        38 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        79 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X