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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    24 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    14 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    9 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    10 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    17 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X