Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting bar# when using MAX() & MIN()

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

    Getting bar# when using MAX() & MIN()

    Hello,
    I am trying to create a swing indicator based on certain periods that I've created. I've used the MAX() and MIN() to determine the highs and lows of these periods. Does anyone know how to then find the specific bar number for those highs and lows?
    Code:
    if (down period) 
    {
         endBarsAgo1 = CurrentBar;
         startBarsAgo = CurrentBar;
         lowest_Low = MIN(Low, endBarsAgo1 - startBarsAgo1 )[1];
    }
    if(up period)
    {
         startBarsAgo1 = CurrentBar;
         endBarsAgo = CurrentBar;
          highest_High = MAX(High, endBarsAgo - startBarsAgo)[1];
    }
    The MAX() and MIN(), of course, are good for finding the highs and lows for a specific period, but do not give the bar number.

    #2
    Hello CaptainAmericaXX,

    Thanks for your post.

    To find the Highest or Lowest bar in a defined period, you can use the following methods:





    You may want to use these methods to find the Highest and Lowest bars first then the High and low value of those bars.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    630 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    566 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X