Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LowestBar

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

    LowestBar

    Hi,

    I'm trying to locate the bar with the lowest low in a series of bars.

    the formula I'm using is LowestBar(Low, (startbar-endbar))

    The code is correctly identified the startbar and endbar when i checked.
    however it has always identified the end bar (bar 0) as the bar with the lowest low which isn't the case.

    What am I doing something wrong here?

    Regards

    Kay Wai

    #2
    Hi, could it be that the startbar has a lower value than the endbar, and therefore you are passing in a negative value into the LowestBar method?

    Try this:
    LowestBar(Low, (endbar - startbar))

    Comment


      #3
      @tmc_ thank you for that. that worked.

      isn't the currentbar, 0 and the earlier bars have the larger numbers?

      Comment


        #4
        It depends on what you store inside the "startbar" and "endbar" variables. You might store bar index (CurrentBar) or bars ago (0 = last bar). The LowestBar method requires you to pass in series and how many bars ago it should look for the lowest low. So logically, if you are storing bar index there, then I assume the start bar has a lower value than the end bar so you need to pass in the absolute value of the difference into the method. https://ninjatrader.com/support/help...tml?charts.htm

        To further clarify, the CurrentBar is an index of a bar inside the bars collection, which starts at an index of 0 (the very first bar on the chart) and increases with each new bar up to the collection size minus one (the very last bar).
        Last edited by @tmc_; 11-20-2021, 08:36 AM.

        Comment


          #5
          Hello kaywai,

          As @tmc_ pointed out this could relate to your variables. It was also noted that the LowestBar method takes a bars ago or Period which needs to be greater than 0. You could add a Print before that line to identify what the value you calculate is:

          Code:
          Print(endbar - startbar);
          You could also just as a test try the help guide sample to see if you get a different result.



          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          635 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          365 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          106 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          571 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X