The Fractal Bands is a implementation of the Fractal Dimension into the Bollinger Bands. It’s purpose is to find potential mean reversion opportunities when price touch the upper or lower bands. The upper and lower bands are built open a FRASMA (Fractally Modified Simple Moving Average)
e_period (integer): This is the period considered for calculating the fractal dimension, default is 30.
normal_speed (integer): This is the speed of the SMA before being modified to become the FRASMA, default is 30.
alpha (real): This is the alpha from equation (2), default is 2.
Note from the author (Jean-Philippe Poton) about the use of the indicator:
The strategy is quite straightforward.
I enter in a BUY position after the price have rebounded (after touching it) from the lower band and crossed the FRASMA, my Stop Loss is then set to the level the prices hit the lower band, and my Take Profit is when the prices hit the higher band.
Symmetrically, I enter a SELL position after the price have fallen from the higher band (after touching it) and crossed the FRASMA, Stop Loss set at the level of the hit of the higher band, and Take Profit when the lower band is hit.
It is obviously possible (and even advised) to make your Stop Loss trailing the price changes.
I used this strategy for EUR/USD on a 5 minutes timeframe, using it on other timeframes or on other instruments may require a different setup, mine was to set the speed of the FRASMA at 30, and α=2 (in equation (2) above), it is possible to change these values.
Indicator translated from MT4 version by a request in the French forum.
//PRC_Fractal Bands | indicator
//10.07.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//translated from MT4 code
//---settings
//eperiod =30
//normalspeed =30
//alpha =2.0
//---end of settings
shift=0
etypedata =customclose
gperiodminus1=eperiod - 1
log2=log(2.0)
inputData=etypedata
priceMax = highest[eperiod](inputData)
priceMin = lowest[eperiod](inputData)
length =0.0
priorDiff=0.0
for iteration=0 to gperiodminus1 do
if((pricemax-pricemin)>0.0) then
diff=(inputdata[iteration]-pricemin)/(pricemax-pricemin)
if iteration>0 then
result=square(diff-priordiff)+(1.0/square(eperiod))
length=length+(sqrt(result))
endif
priordiff=diff
endif
next
if (length>0.0) then
fdi=1.0+(log(length)+log2)/log(2*gperiodminus1)
else
fdi=0.0
endif
hurst=2-fdi // The Hurst exponent
traildim=1/hurst // This is the trail dimension, the inverse of the Hurst-Holder exponent
beta=traildim/2
speed=Round(normalspeed*beta)
ExtOutputBuffer=average[speed](close)//iMA(NULL,0,speed,0,0,0,pos); // Buffer of the FRASMA
sum=0.0
k=gperiodminus1
frasma=ExtOutputBuffer[shift]
while(k>=0) do
newres=Close[k]-frasma
sum=sum+(newres*newres)
k=k-1
wend
deviation=2*Sqrt(sum/eperiod) // 2 standard deviations around the frasma
UpperBuffer=frasma+deviation*exp(hurst*log(alpha))
LowerBuffer=frasma-deviation*exp(hurst*log(alpha))
return upperbuffer,lowerbuffer,ExtOutputBuffer style(line,2)