Williams fractal indicator: 5-bar rule, confirmation delay, backtest
A Williams fractal is a five-bar pattern whose middle bar is the highest high (up fractal) or the lowest low (down fractal). It is known only at the close of the second bar after the middle bar, so a fair rule acts on the next bar after that, pays costs on every trade, and is judged against the settings around it.
By Soren Huang · Published · updated · Editorial policy
Contents
What is the Williams fractal indicator?
The Williams fractal indicator marks a bar whose high is higher than the two bars before and the two bars after it (an up fractal), or whose low is lower than those four neighbours (a down fractal). The arrow sits on the middle bar, but the pattern is complete only two bars later, so a fair rule acts after that.
A Williams fractal is a five-bar pattern that marks a local turning point: an up fractal is a bar whose high is higher than the two highs before it and the two highs after it, and a down fractal is a bar whose low is lower than the two lows before it and the two lows after it. Written as a condition for an up fractal:
High[t] > High[t−1], High[t−2], High[t+1] and High[t+2]
Here t is the middle bar, t−1 and t−2 are the two bars before it, and t+1 and t+2 are the two bars after it. The down fractal swaps High for Low and "higher" for "lower". Nothing else goes into it: no average, no smoothing, no lookback setting. That makes it one of the simplest items in any list of technical analysis tools and indicators you can actually test, because the whole rule fits in one line.
Two details decide whether your test matches your chart. First, ties: the simplest form needs the middle high to be strictly higher than all four neighbours, but some charting packages treat an equal high on the outer bars as still valid. Write down which version you use before you test. Second, the fractal says nothing about size. A one-tick wobble in a quiet session and a sharp spike after a news release both qualify, so most traders pair it with a second condition, which the entries section below covers.
Does the Williams fractal repaint?
The fractal arrow does not move once it is drawn, but it is drawn two bars in the past, so any chart or backtest that treats the arrow as known on its own bar is using two bars of future data. Repainting is the behaviour of an indicator whose past values change after later bars arrive; the fractal has a milder but related problem, a fixed confirmation delay. On most charting platforms the arrow appears on bar t only after bar t+2 has closed, because only then can the two lower highs after the middle bar be checked.
Look-ahead bias is the error of letting a backtest use information that was not available at the moment of the decision. For a fractal rule the leak is exactly two bars. A backtest that reads "fractal on bar t" and buys on bar t is buying at a local low that it could only identify two bars later, which is like reading tomorrow's newspaper and then placing today's bets. The result looks excellent and is impossible to trade. The general checks for this mistake are in look-ahead bias in backtests and a one-bar check; for fractals the fix is simpler, because the offset is known: shift every fractal signal forward by two bars before you let a rule act on it.
This delay is different from the lag of a smoothed line. A moving average lags because it averages old prices, and variants such as the DEMA indicator that cuts moving-average lag exist to shorten that delay. The fractal's two bars are not lag you can tune away; they are part of the definition. Trying to "speed up" a fractal by acting on a provisional pattern after one bar means trading a different, weaker pattern.
How can you use fractals for entries, stops and breakouts?
Fractals give three testable rules that behave differently: a breakout entry above the last confirmed up fractal, a protective stop beyond the most recent opposite fractal, and a trend filter built from the sequence of fractal highs and lows. All three can only act after the confirmation bar, so each one is tested with the same two-bar shift.
| Rule | What it triggers on | Where the order sits | How often it fires | Earliest action |
|---|---|---|---|---|
| Breakout entry | Price trading above the last confirmed up fractal high (or below the last down fractal low for a short) | Buy stop one tick above the fractal high | Often: every new fractal can set a new level | Order placed at the open of bar t+3; fills when price reaches it |
| Fractal stop | An open position moving against you | Stop one tick beyond the most recent opposite fractal | Once per trade, moved as new fractals confirm | Stop level updated at the open of bar t+3 |
| Trend filter | Comparing the last two up fractals and last two down fractals | No order; it allows or blocks the other rules | Changes state only when the sequence breaks | State updated at the open of bar t+3 |
The breakout entry is the most common use. A buy stop is an order that becomes a market order once price trades at or above a level you set, so placing it one tick above the last up fractal means you enter only if price actually clears that local high. The fractal stop uses the same idea in reverse: the most recent down fractal is the last place buyers stepped in, so a stop just below it exits when that level fails. The trend filter reads structure: higher up fractals and higher down fractals in sequence describe an up trend, and the reverse describes a down trend. On intraday bars the two-bar delay is a few minutes rather than two days, which changes how useful each rule is; what testing shows about the best indicator for intraday trading explains why short bars punish rules that fire often.
Hypothetical example
On an index future, an up fractal confirms with a high of 5,040. You place a buy stop at 5,040.25. Two bars later price trades through it and you are long at 5,040.50 after slippage. The most recent down fractal low is 5,010, so your stop goes to 5,009.75, a risk of about 30.75 points. When a new, higher down fractal confirms at 5,025, you move the stop to 5,024.75. The trade is never managed from an arrow on the current bar; every level comes from a fractal that is already two bars old.
Because a plain fractal fires on noise as readily as on real turns, the filter matters as much as the entry. The fractal sequence is one filter; a measure of how random recent prices have been, such as the entropy indicator that measures market randomness, is another kind, and the two can be tested side by side on the same breakout entry.
How do you backtest a fractal rule with next-bar execution and costs?
A fair fractal backtest fixes the confirmation offset at two bars, fills at the open of the bar after the signal, charges commission and slippage on every trade, and reads the result as one candidate kept from many tried. Next-bar execution is the rule that a signal computed from a bar's close can only be filled on the following bar, because the close is not a tradable price for a decision made at the close.
- Define the fractal with offset 2. The code or rule builder must evaluate "fractal at bar t" only when bar t+2 has closed. If your tool plots the arrow back on bar t, confirm that the signal variable is still delayed.
- Raise the signal on the close of bar t+2. Any filter, such as the fractal trend sequence, is evaluated at the same moment with the same delayed data.
- Fill at the open of bar t+3. For a buy-stop breakout, place the order at that open and let it fill when price reaches the level, with slippage added.
- Charge commission and slippage on every trade. Breakout entries fill on stop orders, which usually fill worse than the trigger price; how to model commission and slippage in a backtest covers how to set the numbers.
- Compare the average trade after costs with the round-trip cost. A rule that fires on every small fractal has many trades and a small average move, which is the combination costs destroy first.
The run below shows what the output of such a test looks like in practice. The test ran on ES daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, with $20 commission and $25 slippage charged per trade. The rule is a stand-in: a Record Test rule built from standard indicators, used as the only entry and exit, with no stop, no target and no filter. It is not a Williams fractal rule, so its numbers describe the test setup, not the indicator. The candidate shown is the one the search kept out of just over a thousand it tried, chosen for its return against its drawdown. Picking the kept one after the fact flatters it, in the way Bailey, Borwein, López de Prado and Zhu (2014) describe: the best of many backtests on the same data carries a selection bonus that new data will not pay. No rule earned this money, and no reader should expect it.
Source: AlphaPrime product engine (CPU), run 2026-10-31. ES daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $25 slippage per trade.
| Number | Result |
|---|---|
| Net profit (closed trades) | $56,377.5 |
| Max drawdown | $30,507.5 |
| Trades | 98 |
| Win rate | 60.2% |
| Profit factor | 1.498 |
| Average trade | $575.28 |
| Time in market | 34.26% |
What to read from it: 98 trades over six and a half years is a thin sample, so the average trade of $575.28 is an estimate with wide error bars, not a measurement to the dollar. The $45 of commission and slippage per trade is a small part of that average, which is what a daily-bar rule should show; a one-minute fractal rule would show the opposite picture. The fill and cost settings here are not something you add afterwards: in AlphaPrime (Valynox), backtesting fills every signal on the next bar and charges commission and slippage inside each evaluation, so a fractal breakout is ranked on what it could have paid rather than on where the arrow was drawn.
How do you judge the result and what should you test next?
Judge a fractal test by the average trade after costs against its drawdown and by whether the settings around the chosen one behave alike, then rerun the same rule with the offset set to zero to measure how much a look-ahead version would have flattered it. In the run above, the max drawdown of $30,507.5 is more than half the net profit of $56,377.5, which tells you the path to that profit was uncomfortable, and the single-contract account size needed to sit through it is a separate question from whether the rule has an edge.
Parameter stability is the property that neighbouring settings of a rule give similar results, so that the chosen setting is a plateau and not a lucky spike. A plain fractal has no lookback to vary, but a fractal rule does: the tick offset of the stop order, the number of fractals the trend filter compares, and the session filter. Pardo (2008) describes testing the settings around the chosen one as a standard part of evaluating any optimized rule, and how to tell a parameter plateau from a lucky spike gives the procedure. If a two-fractal filter works and a three-fractal filter fails, the result is describing one stretch of history.
| Property | Offset 2 (tradable) | Offset 0 (look-ahead) |
|---|---|---|
| What the rule knows on bar t | Only bars up to t−2 can be confirmed fractals | Bar t is already a fractal, using t+1 and t+2 |
| Entry price for a long | Open of t+3 or later, after a buy stop fills | Near a local low, before the bounce |
| Equity curve shape | Rougher, with normal drawdowns | Smooth and steep |
| Can it be traded live? | Yes | No |
The offset-zero rerun is the most useful single check for this indicator. Lo, Mamaysky and Wang (2000) make the same point about pattern recognition in general: a pattern defined by points on both sides of an extreme cannot be known at the extreme, and a test must respect that window. If your offset-zero version is dramatically better than your offset-two version, you have measured the leak, and you now know how much to distrust any fractal result whose author did not state the offset.
Hypothetical example
A fractal breakout rule on daily bars shows an average trade of $900 after costs with offset 0 and $300 with offset 2, from the same 120 trades. The $600 difference is not market behaviour; it is the price of knowing two bars early. Only the $300 figure describes something you could have traded, and only it goes forward to the next check.
Next step: take your own bar data, build the breakout entry with the two-bar offset, charge your real commission plus at least one tick of slippage per side, and read the average trade after costs. Then set the offset to zero, run again, and write down the gap. Finally vary the stop offset and the filter length one step in each direction; if the neighbours agree with the chosen setting, the rule has earned a walk-forward test.
Frequently asked questions
Can the fractal indicator be backtested?
Yes, as long as the test delays every fractal signal by two bars and fills on the bar after that. A fractal is defined by two bars on each side of its middle bar, so it exists only at the close of the second later bar. A backtest that acts on the middle bar uses future prices and cannot be reproduced live. With the delay in place, add commission and slippage on every trade and compare the average trade with the round-trip cost.
What settings does the Williams fractal indicator have?
The standard fractal has none: it is always five bars, with the middle bar as the extreme. Some platforms let you widen the pattern to three or more bars on each side, which produces fewer, larger turning points and a longer confirmation delay. The settings that matter in a strategy belong to the rule around the fractal: the tick offset of the stop order, how many fractals the trend filter compares, and which session is traded.
Is a Williams fractal the same as a swing high or swing low?
It is one specific definition of a swing point. A swing high in general means a local high with lower highs on both sides; the Williams fractal fixes the number of bars on each side at two. Other swing definitions use three, five or more bars, or a minimum price distance. The fractal's advantage is that the rule is exact, so two people testing it on the same data mark the same bars.
Why does the fractal arrow appear two bars late on my chart?
Because the pattern needs the two bars after the middle bar to be complete before it can be confirmed. The chart draws the arrow on the bar where the extreme happened, but it can only draw it once those two later bars have closed. This is not a bug and not repainting; it is the definition. Any trading rule built on the arrow must wait for the same two bars.
References
- Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
- Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies (2nd ed.). John Wiley & Sons.
- Lo, A. W., Mamaysky, H., & Wang, J. (2000). Foundations of Technical Analysis: Computational Algorithms, Statistical Inference, and Empirical Implementation. The Journal of Finance, 55(4), 1705–1765.

