This ProBuilder script is designed to plot range zones that span overnight from one trading day to the next across the entire historical data set. The zones are visualized using rectangles that highlight the high and low prices between specific time intervals.
defparam drawonlastbaronly=true
start = time>=180000 and time<235900
end = time<080000 and time>=000000
if time=180000 then
i=i+1
$x1[i]=barindex
$y1[i]=low
$y2[i]=high
hh=high
ll=low
endif
if start or end then
$x2[i]=barindex
ll=min(ll,low)
hh=max(hh,high)
$y1[i]=ll
$y2[i]=hh
endif
if islastbarupdate and isset($x1[2]) then
for y = 1 to i do
drawrectangle($x1[y],$y1[y],$x2[y],$y2[y]) //plot in history
next
endif
return //hh,ll
The code snippet above is structured to perform the following steps:
defparam drawonlastbaronly=true setting ensures that drawing commands are executed only on the last available bar of data to optimize performance.This approach is useful for visually analyzing price movements and behaviors during specific overnight trading sessions across historical data.