This ProBuilder code snippet is designed to find and plot the closest daily high and low prices relative to the current price on a chart. It is particularly useful for traders who want to visualize significant price levels from previous days that might act as support or resistance.
defparam drawonlastbaronly=true
//saving the daily high/low while reading the history
if day<>day[1] then
$dh[i]=dhigh(1)
$dl[i]=dlow(1)
i=i+1
endif
//find the closest daily high/low
if islastbarupdate then
hh=0
ll=close*1000
lasthhdiff=0
lastlldiff=0
for a = 0 to i do
hhdiff=abs($dh[a]-close)
if hhdiff
This code operates in two main phases: data collection and analysis.
day<>day[1]). If it is, it stores the daily high and low prices into arrays $dh and $dl respectively. The index i is incremented each day to keep track of the number of entries.islastbarupdate), it initializes variables to store the closest high (hh) and low (ll) and their respective differences from the current price (lasthhdiff, lastlldiff). It then iterates through all stored daily highs and lows, calculating the absolute difference from the current price. If a smaller difference is found, it updates the closest high or low and the smallest difference found so far.drawhline.This snippet is useful for visualizing important price levels that could influence future price movements.
Check out this related content for more information:
https://www.prorealcode.com/topic/insertion-indicateur-plus-haut-plus-bas/#post-145630
Visit Link