This ProBuilder code snippet demonstrates how to draw support rectangles on a chart until the price breaks through the support level. The rectangles are drawn based on historical low prices and are adjusted or removed when the price breaks below these levels.
defparam drawonlastbaronly=true
REM Store support
IF high[2] < low THEN
$support[i]=low
$support1[i]=high[2]
$bar[i]=barindex
$bar1[i]=barindex[2]
i=i+1
ENDIF
REM check support line if islastbarupdate and i>1 then
for j = 0 to i-1
checklow = $support[j]
bars = max(1,barindex-$bar[j])
endbar=barindex
for z = 1 to bars
if low[z]
Explanation of the Code:
drawonlastbaronly=true ensures that drawing commands are executed only on the last bar of the chart to optimize performance.drawrectangle with a semi-transparent green fill and no border to visually represent support areas. The rectangles adjust or terminate based on price action relative to the support level.This snippet is useful for traders and analysts who use technical analysis in their strategy, providing a visual tool to observe and react to price support levels dynamically.
Check out this related content for more information:
https://www.prorealcode.com/topic/fin-conditionnelle-de-trace-dun-rectangle/#post-221080
Visit Link