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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    133 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    75 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    117 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    113 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    90 views
    0 likes
    Last Post CarlTrading  
    Working...
    X