Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MIN / MAX funtion problem

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

    MIN / MAX funtion problem

    Hi support,
    I have figured out that both MIN and MAX function using an array do have a negative impact on the performance/speed of a strategy. Using those functions cause a slow strategy. Do you have any suggestion about an alternative or workaround for both functions in order to speed up the strategy?

    Kind regards,
    Rene

    #2
    Hi Renejm,

    Thank you for your post.

    You can use HighestBar() and LowestBar() in their place. Below are two links on how to use these functions.

    HighestBar()
    LowestBar()

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks. Is there any way I can exclude the current bar for the HighestBar/LowestBar function, because I don't want to include the current bar. With MIN and MAX you have the possibility for Min()[1] so that the current bar will not be included.

      Kind regards,
      Rene

      Comment


        #4
        Hi Rene,

        You would need to create a for loop for the logic and store it in a temp variable for the highest or lowest value. You would need to define the temp variable outside the loop.

        Example -
        Code:
        for( int i = 1; i < period; i++)
        {
        //Logic
        }
        Let me know if this is the answer you are looking for.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by Renejm View Post
          Thanks. Is there any way I can exclude the current bar for the HighestBar/LowestBar function, because I don't want to include the current bar. With MIN and MAX you have the possibility for Min()[1] so that the current bar will not be included.

          Kind regards,
          Rene
          If you do not want to include the current bar, you can limit the calculation of MIN and MAX to one time per bar

          Code:
          if(FirstTickOfBar)
          {
             // calculate Minimum or Maximum over the lookback period
          }
          This only will lead to a reduction in CPU load, if you execute a strategy in COBC = false. It will not improve the speed of a backtest.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          88 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          30 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          34 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          68 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X