HighestBars

Category: Instructions

HighestBars is a function in the ProBuilder language used to determine the position of the highest value within a specified period of past data. This function is particularly useful in financial chart analysis, helping to identify the peak value of a data series like price or volume over a given range.

Syntax:

HighestBars[Period](source)

The Period specifies the number of past bars to consider, and source indicates the data series (such as close, high, low, etc.). The function returns the offset (number of bars back) to the bar with the highest value. If no highest value is found within the specified period, it returns -1.

Example:

myHighest = HighestBars[10](close)
IF myHighest > 0 THEN
    DRAWTEXT("Highest close in last 10 bars", barindex - myHighest, close[myHighest])
ENDIF

In this example, HighestBars[10](close) checks for the highest closing price in the last 10 bars. If a highest value is found at least 1 bar ago (i.e., myHighest is superior to 0), it draws a text label at the bar where the highest close occurred.

  • The function is zero-based; thus, an offset of 0 indicates the current bar.
  • If multiple bars have the same highest value, the function returns the first occurrence starting from the current bar and looking backwards.

This function is essential for traders and analysts who need to pinpoint significant peaks in price or other data series over a specified timeframe, aiding in the decision-making process related to trading strategies.

Related Instructions:

  • Highest indicators
  • Lowest indicators
  • LowestBars instructions
  • Logo Logo
    Loading...