This ProBuilder code snippet is designed to find the nearest fractal low to a specified price level within a limited number of bars. It utilizes fractal lows to determine potential support levels in trading data.
// settings
priceLevel = 1.17178
FractalPeriod = 3
barLimit = 200
// defining low fractals
cp=FractalPeriod
if low[cp] <= lowest[2*cp+1](low) then LL= -1 else LL=0 endif if LL = -1 then LOL = low[cp] DRAWTEXT("▲",barindex[cp],lol,Dialog,Bold,12) fractal=lol endif // looking for the nearest fractal to priceLevel diff=priceLevel*10 lastfractal=0 lastdiff=0 for i = 0 to barLimit-1 do if fractal[i]>0 and lastFractal<>fractal[i] then
diff=min(diff,abs(fractal[i]-priceLevel))
if diff<>lastdiff then
nearestFractal=fractal[i]
endif
lastFractal=fractal[i]
lastdiff=diff
endif
next
return nearestFractal,pricelevel coloured(200,200,0)
This code snippet performs the following steps:
This example is useful for understanding how to implement and utilize fractal-based support levels in trading algorithms using ProBuilder language.
Check out this related content for more information:
https://www.prorealcode.com/topic/comparer-valeur-precedente-dans-boucle/#post-146706
Visit Link