Bill Williams Fractals

Bill Williams Fractals

“In order for a fractal to form, there should be a series of 5 consecutive bars where the middle bar will be the highest preceded and followed by two lower neighbouring bars on each side.”

Since this indicator is frequently requested on forums, I put the code here (author: SOHOCOOL).

Fractals can be used in many different approach:

  • Market points reversal
  • Breakout of recent fractals points
  • Trend line drawn from recent fractals

The “Low Fractal” and “High Fractal” may be set to ‘points’ style in the platform to have a clearer view of them on the price chart. 

 

 

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 : How to import ITF files into ProRealTime platform?

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

  1. Doctrading • 05/24/2016 #

    Hi Nicolas,
    Thanks for sharing, interesting code.
    Maybe someone could make a strategy based on it.Best regards,

  2. from8to800 • 05/24/2016 #

    I get the lines, but cannot get the segments?

    • Nicolas • 05/24/2016 #

      set the “Low Fractal” and ‘High Fractal” to points and not lines.

  3. from8to800 • 05/24/2016 #

    If you do it like follows, it prints arrows instead of lines.
    You’re welcome.
    if high[cp] >= highest[2*cp+1](high) then
    LH = 1
    else
    LH=0
    endif

    if low[cp] <= lowest[2*cp+1](low) then
    LL= -1
    else
    LL=0
    endif

    if LH=1 then
    DRAWARROWUP(barindex[2], high[cp]*1.05)
    endif

    if LL = -1 then
    DRAWARROWDOWN(barindex[2], low[cp]*0.93)

    endif
    RETURN
     

    • Nicolas • 05/24/2016 #

      Thanks a lot! Share of any kind are always appreciated! 😉

  4. viggy • 05/24/2016 #

    Hi,
    Thanks for posting this, I have tried to put it on my charts but I am getting it in a separate window rather than on the chart, is there anything I have to do with the settings?
    I tried the other one with the arrows but I am getting an error with line 14 and 15 due to a ( not being expected?
    I would really appreciate any help, 
    Kind regards, 
    Vig

    • Nicolas • 05/24/2016 #

      Please use the wrench on the upper left corner of the chart to add an indicator on the price chart. The other indicators with arrows is only compatible with prorealtime version 10.3.

    • stevzor • 05/24/2016 #

      Hi – bit of an old post but hopefully you see my comment lol.

      I’m trying to add this Williams Fractal indicator to my ProRealtime charts and it’s not working, it adds like a box on the bottom ( same way MACD or RSI does) and not on the actual price chart.

      I use 70 tick charts, any ideas? Thanks!

    • Nicolas • 05/24/2016 #

      Add it on the price by using the wrench on the left upper side of the price chart.

  5. viggy • 05/24/2016 #

    Hi Nicolas, 
    Thank you for the quick reply and I have now been able to get the indicator on the price rather than in a separate window. 
    My next question is I now have two consecutive lines like a bollenger bands rather than lines at the highs and lows of the price. How do I get it to look like the picture above? I am running 10.2 is that the problem?

    • Nicolas • 05/24/2016 #

      Set it as points and not lines, in the indicator’s window parameters.

  6. viggy • 05/24/2016 #

    Perfect, thank you Nicolas! 🙂

  7. Sam Ventura • 05/24/2016 #

    ça marche pas PRT me dit erreur de syntaxe : cp ? veuillez définir la variable 

    • Nicolas • 05/24/2016 #

      Bien entendu, la ligne 4 est commenté! 🙂

  8. Sam Ventura • 05/24/2016 #

    OK mais on fait comment, pour un gros nul de la programmation comme moi ?

    • Nicolas • 05/24/2016 #

      Il faut simplement supprimer les // ou ajouter cette variable dans les paramètres de l’indicateur

  9. Sam Ventura • 05/24/2016 #

    je comprend pas ? ça ma marche pas
    il faudrait un exemple, merci

    • Nicolas • 05/24/2016 #

      La ligne 4 doit ressembler à ceci:
      cp = 2
      Tu pourras changer la valeur 2 par celle qui te convient également.
       

  10. Sam Ventura • 05/24/2016 #

    ça donne pas le même indicateur que celui montrer ? c’est normal
     

    • Nicolas • 05/24/2016 #

      “cp”, c’est un paramètre que l’on peut modifier à volonté. Sinon pour avoir les points, il faut paramètrer les valeurs retournées en mode “point”.

  11. Elsborgtrading • 05/24/2016 #

    Hi, the ver, with arrows is this only for PRT, 10.3?
    I get errors in ver 10.2
    Cheers Kasper

  12. Elsborgtrading • 05/24/2016 #

    I can see that the graphical instruction for DRAWARROW is only for PRT V.10.3 so there’s the error.

  13. tradingpro • 05/24/2016 #

    buongiorno
    cosa si deve mettere al posto di 
    DRAWARROWUP
    mi potete dare un codice gia completo per il fractal?grazie

  14. fab • 05/24/2016 #

    Syntax errors for ver 10.2, not tried it on 10.3. 
    Any of you get this to work on 10.2??
    cheers

    • Nicolas • 05/24/2016 #

      Please uncomment the line 4 or use the imported ITF file instead.

  15. xtremriders • 05/24/2016 #

    Hi there Here is the code than i had to modifie a bit as the arrows weren’t in the right places,above/under the candles. I have also added colour for better understanding.

    cp=2

    if high[cp] >= highest[2*cp+1](high) then
    LH = 1
    else
    LH=0
    endif

    if low[cp] <= lowest[2*cp+1](low) then
    LL= -1
    else
    LL=0
    endif

    if LH=1 then
    DRAWARROWUP(barindex[2], high[cp]+0.0001)coloured(0,255,0)
    endif

    if LL = -1 then
    DRAWARROWDOWN(barindex[2], low[cp]-0.0001)coloured(255,10,10)

    endif
    RETURN

    • Nicolas • 05/24/2016 #

      Thank you for sharing this modification. In previous PRT version (before 10.3), it was impossible to draw in past history, that’s why the fractals were not placed at the exact fractals candlesticks.

  16. Ciccio • 05/24/2016 #

    Slightly modified, for those interested (I hope I didn’t make mistakes)
     
    /////////// FRACTALS BILL WILLIAMS//Variable:
    //cp = 2 (default)
    cp = 2
    if (High[cp] > High[cp+2]) AND (High[cp] > High[cp+1]) AND (High[cp] > High[cp-1]) AND (High[cp] > High[cp-2]) thenLH = 1elseLH=0endif
    if (Low[cp] < Low[cp+2]) AND (Low[cp] < Low[cp+1]) AND (Low[cp] < Low[cp-1]) AND (Low[cp] < Low[cp-2]) thenLL= -1elseLL=0endif
    if LH=1 thenDRAWARROWUP(barindex[cp], High[cp]*1.0008) COLOURED(0,10,255)endif
    if LL  = -1 thenDRAWARROWDOWN(barindex[cp], Low[cp]*0.9992) COLOURED(255,0,10)
    endifRETURN
    /////////////end

  17. Ciccio • 05/24/2016 #

    What is the piece of code that must be added to make it draw lines, to the extreme right of the chart, from the 2 most recent fractals?

  18. Ciccio • 05/24/2016 #

    … in a few words a Fractal Channel….

  19. Ciccio • 05/24/2016 #

    … that you posted at the beginning
    sorry… delete post if you want

  20. adamalaska • 05/24/2016 #

    Hello there Nicolas,
    Is there a way of coding the arrow fractal for it to alarm when it appears?
    Thank you,
    Adam

    • Nicolas • 05/24/2016 #

      You can already use the alarm tool to trigger alerts with the red/green dots of this indicator. 

  21. Real Pro • 05/24/2016 #

    Why do I get this error when I try to add the arrows please?

    “One of the following characters would be more suitable than “if”?”

    • Nicolas • 05/24/2016 #

      Try the code from this comment: https://www.prorealcode.com/prorealtime-indicators/bill-williams-fractals/#comment-1000

  22. Real Pro • 05/24/2016 #

    Thanks Nicolas. Same response. It gives an error for the word ‘if’.

    • Nicolas • 05/24/2016 #

      Do you have version 10.3? What broker?

  23. Real Pro • 05/24/2016 #

    Yes 10.3, IG Markets.

  24. mcha • 05/24/2016 #

    Merci Nicolas,
    j’ai pris l’option points ce qui fait des quasi segment sur des UT courtes ( jour) mais en hebdo c’est plus light, est-ce possible d’avoir un segment continu (l’option proposée par PRT ligne + points génère des lignes reliant les fractales ce qui alourdit le graphe). Merci par avance

  25. adayag • 05/24/2016 #

    Hi, I was looking for an asymmetrical fractal to be set on Pro Real Time and I have found the code on this page. Unfortunately it gives a syntax error: define the variable cp

    • Nicolas • 05/24/2016 #

      Yes define it. Uncomment the cp variable (delete the //) or just download the itf file and import it directly into the platform to get this setting available in the indicator’s window.

  26. adayag • 05/24/2016 #

    Thank you. I could upload it on the Pro Real Time platform, but it is not the same indicator in the Image. It shows a green segmented line above, a red segmented line below and a Grey area between them. I need an indicator for the poitioning of a continuously moving stop loss (like a trailng stop). Here it is better explaied: https://www.dailyfx.com/forex/education/trading_tips/daily_trading_lesson/2014/05/09/The-More-Intelligent-Trailing-Stop.htmlhttps://www.dailyfx.com/forex/education/trading_tips/daily_trading_lesson/2014/05/09/The-More-Intelligent-Trailing-Stop.html

    • Nicolas • 05/24/2016 #

      You only need to set these lines to points in the indicator settings.

  27. adayag • 05/24/2016 #

    I deleted the //, but it gives a further error on line 4

    • Nicolas • 05/24/2016 #

      Please download the file and import it.

  28. adayag • 05/24/2016 #

    Hi Nicolas, thank you for your answer. Nothing has been changed after having applied your instructions. The indicator that I have is completely different from what is expected to be. How can I send you a screenshot?

  29. adayag • 05/24/2016 #

    You can find the screenshot at the following link: https://ibb.co/gfvPkR
    I hope it helps

    • Nicolas • 05/24/2016 #

      Please add it on your price chart instead (click on the wrench on the left upper side of your price chart) and remove the color zone.

  30. adayag • 05/24/2016 #

    Hi Nicolas, thank you for your answer. I clicked on the wrench but after that I don’t know where to remove the color zone. I have also asked my broker.

    • Nicolas • 05/24/2016 #

      To remove the color zone, just delete it in the indicator settings.

  31. adayag • 05/24/2016 #

    I would like to have the same Indicator showed at the beginning of this page. It would be comprehensible for me with the same settings that are in the Image, otherwise I don’t know to read it

  32. crolakstrading • 05/24/2016 #

    Hi Nicolas, is it possible to make this into the black background?? as when you put this into the black background on PRT.. it shows a white colour in between the green and red lines?

  33. crolakstrading • 05/24/2016 #

    oops sorry.. i manage to get that out!! thanks!!

  34. Diego Alonso Garrido • 05/24/2016 #

    How its possible to change the number of candles needed for the fractal formed???
    Thanks

    • Nicolas • 05/24/2016 #

      Yes, change the quantity with the Cp variable at the beginning of the code.

  35. jtmoney • 05/24/2016 #

    Hi, great indicator. However, when I put it on as an indicator it doesn’t show up the chart but rather a new indicator tab below. Sorry if this is basic, I’m quite new. Any thoughts? Thanks very much!

    • Nicolas • 05/24/2016 #

      add it on price by using the wrench at the upper left side of the price chart.

  36. rollersk8er • 05/24/2016 #

    Hi Nicolas, I am trying to change this indicator to work with 3 candles instead of 5 but cannot get it to work properly when changing the CP. Any suggestions please?

    Regards

    Patric

    • Nicolas • 05/24/2016 #

      Je vous suggère de faire une recherche sur le site avec le mot clé ‘fractals’, il existe beaucoup de versions différentes, peut-être que l’une d’entre elles vous apportera satisfaction.

  37. Traderfox06 • 05/24/2016 #

    Dear Nicolas,
    all the best for 2019 and thanks for this contribution. I love this indicator, because it combines both powerful Regression and Williams Fractals concepts. Since I am not skilled enough to convert this into an automated scalping system, I really would appreciate if you could give an advice how to code the long/short signals here (see question above from „verygrubby“). At least it would be very helpful to me, to know how I can generate an acoustic signal (just a „beep“) in addition to the point plotting. I know, how to create alerts (https://www.prorealtime.com/en/videos_tutorial/135_create_alerts) but code-generated alerts would be much more flexible. Thanks a lot in advance!

  38. withoutwings • 05/24/2016 #

    Hi All,

    I’ve made some fixes & upgrades so that this single script can either used as an overlay, as a separate indicator panel, or even as a “function” to provide a basic signal (up/down only) for use in automated trading:

    // Required variables (default) [description]:
    // – N (2) [Real-time delay / bars to look both back and forward]

    bwfSig = 0

    r = 255
    g = 255
    b = 255

    IF (High[N] >= Highest[2*N+1](High)) AND (High[N] > Highest[N](High)) THEN
    bwfSig = -1
    ELSIF (Low[N] <= Lowest[2*N+1](Low)) AND (Low[N] < Lowest[N](Low)) THEN
    bwfSig = 1
    ENDIF

    IF bwfSig = -1 THEN
    DRAWARROWDOWN(barindex[N], high[N] + Averagetruerange[100]/3) Coloured(255,10,10)
    r = 204
    g = 0
    b = 0
    ELSIF bwfSig = 1 THEN
    DRAWARROWUP(barindex[N], low[N] – Averagetruerange[100]/3) Coloured(0,255,0)
    r = 0
    g = 153
    b = 0
    ENDIF

    RETURN bwfSig Coloured (r,g,b) Style(Histogram, 1)

    Again, this does not return the actual levels but that would be trivial to add in as a future upgrade.

    Also note that each signal will arrive ‘N’ periods late – but that is the nature of the beast!

    Enjoy.

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+5 more likes

Related users ' posts
jebus89 Big thanks for sharing this :) Seems to work as expected, good stuff.
xpe74 Top visually, and very efficient. I would like to integrate it as a value in a small algo i...
Nicolas Sorry again, doing my best to fix this problem..
Gianluca Sorry but the 2° code that you posted have some problem it doesn't work
Leo I have to check
Alai-n I also have the same problem that I can not solve especially on LowVolume (Yellow) ... Sorry
Mert No need to apologise, my friend. It is great code. I hope you find a solution soon. Regards.
gabri I think it's because the lookback period changes at every new bar and that means that many c...
Vonasi Thanks for the compliments ALE. If you use any results from it in a strategy then please sha...
CKW this is Awesome tool. thanks Vonasi
Vonasi ....and thank you for the compliment CKW.
Reiner great work:-)
Vonasi Thanks Reiner. that is compliments indeed from the seasonality expert. I have a second vers...
Sagal Hi Vonasi, Can it be presented as a 1 year graph displaying a 5 year average or 10 year aver...
Vonasi I noticed a couple of typo errors in the code. The list of variables lines 4 to 11 should be...
Genotik Thank you for your important contribution this week which is much appreciated! Happy New Yea...
Vonasi No problem. I hope they are useful to someone. Happy and hopefully prosperous New Year to y...
DarioMazza Hi Vonasi, i have a question for you, the comand "pricetype" where did you found it in the ...
Vonasi PriceType is just a variable that I use. The value decides what type of price is used in the...
Vonasi I noticed a couple of typo errors in the code. The list of variables lines 4 to 11 should be...
Vonasi The indicator code can easily be adapted for use as a filter in strategies as well. For exam...
AVT Tested today in manual DAX trading (transcripted to MT and changed look into aka oszillator)...
Vonasi I think that short time frame charts will be too noisy for this indicator. One blue bar real...
Vonasi I forgot to mention in the description that Sunday pivot lines are ignored and Monday's pivo...
AVT Like that, simple and clear!
Vonasi Thanks AVT. I like simple - some people would say that I do simple very well! Sometimes you ...
Nicolas
7 years ago
Nicolas Oui. Pour changer la période, il faudra ajuster la variable MMperiod
macbartin plus la période est grande (en occurrence 20) plus l'indicateur est précis dans les changeme...
Hasardeur Hallo Nicolas, in John Ehlers book "cycle analytics for Traders" from 2013, Mr. Ehlers desc...
MaoRai54 Hi, first of all Happy New Year. Well, I've inserted your indicator in DAX 1h but I cann...
Vinks_o_7 Hi Mao Happy New Year ! This is just an improved RSI where you plot a standard price momen...
SpreadBetMH Hi there, I have V11.1. I get the Indicator but no Arrows on the price. Kind Regards...
Alai-n Ciao Francesco, sei ancora in giro?
Metodi97 This indicator is great but can someone create strategy based on the same indicator it will ...
cervantes2 Buenas tardes y gracias por este magnifico indicador. Queria saber si tienes un proscreener ...
cervantes2 Que busque los valores que la linea verde acaba de cruzar al alza o a la baja
AngelPujalt Tenéis algún screener de este indicador?
Giuseppe68 ciao, ho provato l'indicatore e mi sembra interessante, ma in fase di backtest non riesco ad...
poldoposta veramente bello.....complimenti
Nicolas Formule de l'indicateur Momentum: Le Momentum se calcule avec une simple soustraction pour ...
Roberto1 Hi, can this code be converted for the Nanotrader Platform or for the MT4 Platform?
Nicolas This website is dedicated for PRT programming, but you can still ask for private coding with...
Nicolas
7 years ago
TradeNavigator RSI
TradeNavigator RSI
10
Indicators
Nicolas Tutte le impostazioni che hanno la parola "period" sono quelle dedicate ai periodi di cambio...
GianfrancoCeck Le chiedo una ultima cosa, ossia se è possibile personalizzare l'indicatore con una scritta ...
Nicolas Spiacente che non sia possibile, le coordinate grafiche non sono in pixel ma nel prezzo e ne...
ALE
7 years ago
settival CIAO ALE CREDO DI AVER SETTATO PER BENINO LO SCALPING INDICATOR MA NON VISUALIZZO I SEGNALI ...
graff.laetitia Hello, I'm sorry to bother you, I'm new to trading, I managed to download the indicator but ...
Alby118 i can get it to work? dax 1 min. upload indicator on the4 chart. thank you
swapping merci gabri, on va le mettre à l'essai ;)
Nicolas
7 years ago
Trinity Impulse
Trinity Impulse
5
Indicators
ribou ah d'accord merci beaucoup
domenico nlevel1 non modifica la curva al variare del suo valore
tiger_man_no1 Very nice ; what is the best period input date for DAILY CHART ?

Top