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 cmtjoancolmenero, Yesterday, 03:58 PM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by benmarkal, Yesterday, 12:52 PM
          3 responses
          23 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by helpwanted, Today, 03:06 AM
          1 response
          19 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          11 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          244 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Working...
          X