This ProBuilder script generates a heatmap that visualizes the frequency of price touches within a specified range and period on a trading chart. The heatmap’s color intensity increases with the frequency of price touches, providing a visual representation from black to red.
defparam drawonlastbaronly=true
Period = 120
step = 0.25
hh = Highest[Period](High)
ll = Lowest[Period](Low)
checkprice = ll
if islastbarupdate then
ind=0 //reset index of array
//get the price touch occurrences for each level
while checkprice<=hh do
touch=0 //reset price touch for this price level
for i = 0 to period-1 do
if high[i]>=checkprice and low[i]<=checkprice then
touch=touch+1
$hm[ind] = touch
endif
next
//define color
r = min($hm[ind]*10,255)
//plot the result
//drawtext($hm[ind],barindex+5,checkprice) coloured(r,0,0)
drawtext("█",barindex+5,checkprice) coloured(r,0,0)
checkprice=checkprice+step //increase price check for next round
ind=ind+1 //increase array index
wend
endif
return hh,ll
This script is designed to run on the last bar of the chart only, to ensure performance and relevance of the displayed data. Here's a breakdown of how the code works:
This heatmap can be a useful tool for traders to visualize significant price levels where the market has shown repeated interest over a given period.
Check out this related content for more information:
https://www.prorealcode.com/topic/historique-des-prix/#post-193758
Visit Link