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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
//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) |

### Share this

**Risk disclosure:**

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

**ProRealTime ITF files and other attachments :**

**Filename :**download the ITF files

*How to import ITF files into ProRealTime platform?*

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

Maz• 07/10/2017 #I like this

atlante• 07/10/2017 #je me demande si prorealtime pourrait etre programee sur fonction lorsquún point cgange de clouleur independament de la valeur mis comme condition merci

lizmerrill• 340 days ago #can you provide this code for tradestation, please. Thanks

Nicolas• 340 days ago #No sorry, please use this file instead into a prorealtime trading platform.