Fractal Indicator: The Five-Bar Williams Pattern

Written by Dominic Walsh · Published · Last updated

The fractal indicator implements the original five-bar pattern and stops there. A bar qualifies as an up fractal when its high beats the two bars either side of it. The mark lands on that middle bar, two bars back from where the test runs. There are no filters and no extra logic.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 2: Up Fractal, Down Fractal
Alerts popup, push notification, email, sound
Inputs 7

What the Fractal Indicator draws on the chart

Up Fractal is the magenta marker above the middle bar, drawn with arrow code 217.

Down Fractal is the dodger blue marker below it, drawn with code 218.

Both sit `ArrowOffsetPoints` from the bar, which defaults to `6`.

Codes 217 and 218 are the same symbols MetaTrader uses for its own fractals.

  • Up Fractal: arrow, magenta, width 2, arrow code 217
  • Down Fractal: arrow, dodger blue, width 2, arrow code 218
Fractal indicator on EURUSD H1 marking five-bar pivot highs and lows
Fractal indicator on EURUSD H1 marking five-bar pivot highs and lows

How the Fractal Indicator calculates its values

Comparing five highs

The code reads five highs at once. hL2 and hL1 sit to the left of the pivot, hC is the middle bar, and hR1 with hR0 sit to the right. An up fractal needs hC above all four neighbours.

Mirroring it on the lows

lC must sit below its four neighbours for a down fractal. Highs and lows run as separate tests, so one bar can carry both marks. That happens on a wide outside bar surrounded by narrow ones.

Why the mark sits two bars back

UpBuf writes at index i plus two, which is the pivot rather than the bar being tested. Two newer bars must close before the pattern is complete. So a fractal always appears two bars after the high it marks.

How to read the signals

A fractal is a local turning point, nothing more ambitious than that.

Clusters of them mean the market is chopping in a narrow range.

The two-bar delay is fixed, so use the marks as structure rather than timing.

Many traders draw levels from fractal highs and lows and ignore the marks themselves.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

`EnableAlerts` ships on with `EnablePopup` carrying the message. `EnablePushNotify`, `EnableEmail` and `EnableSound` stay off by default. `SoundFile` names the clip. The check reads the completed pattern, so one message follows each closed bar.

Every Fractal Indicator input

Display settings

Setting What it does Default
ArrowOffsetPoints Pixels of price-offset for arrows. Gap between marker and bar in points, default `6`. 6

Alert settings

Setting What it does Default
EnableAlerts Switches the fractal alerts on as a group, default `true`. on
EnablePopup Raises the terminal dialog on a new fractal, default `true`. on
EnablePushNotify Sends the fractal to the MetaTrader mobile app, default `false`. off
EnableEmail Mails the fractal through the terminal, default `false`. off
EnableSound Plays a file when a fractal prints, default `false`. off
SoundFile Name of the wav file the fractal alert uses, default `alert.wav`. alert.wav
Fractal indicator inputs: ArrowOffsetPoints and the alert switches
Fractal indicator inputs: ArrowOffsetPoints and the alert switches

Settings that fit your chart

Five bars mean different things on different charts, which is the point of using it everywhere. EURUSD H1 is the reference chart, where a fractal covers five hours of trade. On M5 they appear several times an hour. On daily charts each one marks a turn worth drawing a line from.

When the Fractal Indicator fails

A five-bar window is tiny. Most fractals mark noise rather than structure.

The two-bar delay means the marker never appears at the moment of the turn.

There is no size test, so a one-pip pivot counts the same as a fifty-pip one.

Copy the compiled Fractal Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the Fractal Indicator for MT4 and MT5

The zip holds the compiled Fractal Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Why does the Up Fractal marker use arrow code 217?

Because that is the symbol MetaTrader draws for its own fractals. Keeping the code the same means the marks look familiar and stack neatly with the built-in tool. Code 218 does the same job for the Down Fractal below the bar.

How far back does ArrowOffsetPoints push the mark?

Six points from the bar high or low by default. That is a small gap on purpose, since a fractal marks a precise price and a large offset would obscure it. Raise it on charts with tall candles where the marker overlaps the wick.

Why do fractals appear two bars late on H1?

Because the pattern needs two bars on the right of the pivot. On H1 that is two hours of waiting before the middle bar can be confirmed. The delay is structural and applies to every five-bar fractal, not just this build.

Can one bar carry both fractal plots?

Yes. Highs and lows run as separate tests, so a wide bar flanked by narrow ones can beat its neighbours in both directions. It looks odd at first but it is correct, and it usually marks a volatile bar rather than a turn.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Fractal Indicator as one input. Always backtest before trading live.

Category: this is part of our Support and Resistance collection. Then, plainly, browse more Support and Resistance for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment