The Fractal Dimension Index is an indicator that measure the strength of a trend by determining the amount of volatility of the instrument. This indicator is already available in the platform but not available for custom coding in ProScreener or ProOrder. This version can resolve this issue.
N = 30
once fdi=undefined
if barindex >= n-1 then
diff=0
length = 0
pdiff = 0
hh=0
ll=0
FDI=0
HH = highest[N](close)
LL = lowest[N](close)
for Period = 1 to N-1 do
if (HH - LL) > 0 then
diff = (customclose[Period] - LL) / (HH - LL)
if Period > 1 then
length = length + SQRT(SQUARE(diff - pdiff) + (1 / SQUARE(N)))
endif
pdiff = diff
endif
next
if length > 0 then
FDI = 1 + (LOG(length) + LOG(2)) / LOG(2 * (N))
else
FDI = 0
endif
endif
return FDI AS "Fractal Dimension Index"