This ProBuilder code snippet is designed to track the highest and lowest prices within each 15-minute interval on a 1-minute chart. It is useful for traders who need to monitor price ranges over specific intervals while viewing a more granular chart.
DEFPARAM CalculateOnLastBars=1000
IF OpenMinute MOD 15 = 0 THEN
HH = high
LL = low
ENDIF
HH = max(HH,high)
LL = min(LL,low)
RETURN HH AS "High",LL AS "Low"
Explanation of the code:
- DEFPARAM CalculateOnLastBars=1000: This line sets the number of bars to calculate on to 1000. This is useful for performance optimization, especially on high-frequency data like a 1-minute chart.
- IF OpenMinute MOD 15 = 0 THEN: This conditional statement checks if the current minute is the start of a new 15-minute interval. The MOD operator is used to find the remainder of the division of OpenMinute by 15. If the remainder is 0, it means a new 15-minute period has started.
- HH = high and LL = low: If it’s the start of a new 15-minute interval, the high and low values are initialized to the current bar’s high and low prices, respectively.
- ENDIF: This marks the end of the conditional block.
- HH = max(HH,high) and LL = min(LL,low): These lines update the high (HH) and low (LL) values for the current 15-minute interval. HH is set to the maximum of the current high and the previously recorded high, and LL is set to the minimum of the current low and the previously recorded low.
- RETURN HH AS “High”,LL AS “Low”: Finally, the highest and lowest values for the current 15-minute interval are returned as output, labeled “High” and “Low”.
This snippet is particularly useful for analyzing price movements within fixed intervals on charts with higher granularity, allowing traders to make informed decisions based on short-term price extremes.