VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

Fibonacci retracement: how to draw it, use it and backtest it

Fibonacci levels are drawn at 38.2%, 50% and 61.8% of a price swing. To learn whether they help, fix the swing rules, write exact entries and exits, include costs, and test on out-of-sample data against nearby levels.

By · Published · updated · Editorial policy

Contents
  1. How do you use Fibonacci retracement, and can you backtest it?
  2. How do you draw Fibonacci retracement levels?
  3. Which swing high and low should you use?
  4. How do you turn a Fibonacci retracement strategy into testable rules?
  5. Do Fibonacci levels add anything beyond a normal pullback?
  6. How do you test on out-of-sample data and check nearby settings?
  7. Frequently asked questions
  8. References

How do you use Fibonacci retracement, and can you backtest it?

Fibonacci retracement draws horizontal levels at 38.2%, 50% and 61.8% of a price swing, measured back from the swing's end. Traders watch these levels as possible pullback entries. You can test the idea. Define the swing with fixed rules and write exact entry and exit rules. Include costs. Then check out-of-sample data and nearby level settings.

The drawing takes seconds. Most of the work in testing is turning a hand-drawn, subjective tool into rules that a computer applies the same way every time. The levels are drawn by hand, so they are harder to test than most technical indicators until the drawing rule is fixed.

How do you draw Fibonacci retracement levels?

You draw the levels between one swing low and one swing high, and the percentages show how far price has pulled back into that move. Fibonacci retracement is a set of horizontal price levels placed at fixed percentages of the distance between a swing low and a swing high. A swing high is a peak where price stopped rising and turned down. A swing low is the opposite: a low point where price stopped falling.

  1. Find the move. In an uptrend, pick the swing low where the move started and the swing high where it ended.
  2. Draw from start to end. In most charting tools you click the swing low first, then the swing high. In a downtrend you click the swing high first, then the swing low.
  3. Read the levels. The tool places lines at 23.6%, 38.2%, 50%, 61.8% and often 78.6% of the move. In an uptrend they sit below the high. In a downtrend they sit above the low.

The price of each level in an uptrend is:

Level = H − r × (H − L)

Here H is the swing high, L is the swing low, and r is the ratio as a decimal (0.382, 0.5 or 0.618). In a downtrend, add the same distance to the swing low instead.

The ratios come from the Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …). Each number is the sum of the two numbers before it. Divide a number by the next one and the result moves toward 0.618. Divide it by the number two places later and the result moves toward 0.382. The 50% level is not a Fibonacci ratio. Traders include it because a half-way pullback is a common reference point.

Hypothetical example

A futures contract rises from a swing low of 2,000 to a swing high of 2,100. The move is 100 points. The 38.2% level is 2,100 − 38.2 = 2,061.8. The 50% level is 2,050. The 61.8% level is 2,038.2. The 78.6% level is 2,021.4. A trader who buys pullbacks watches the zone between 2,038.2 and 2,050.

Fibonacci retracement drawn on a hypothetical 100-point swing from a swing low to a swing high: price pulls back into the shaded 50% to 61.8% zone, about 38 to 50 points above the low, and then rises again The 50–61.8% pullback zone A 100-point swing, hypothetical Swing high 50–61.8% +38–50 pts Swing low Each level is a share of the move. So: fix the swing rule first.
Retracement levels drawn from the swing low to the swing high of the hypothetical example above. The shaded band is the 50% to 61.8% zone that many traders watch.

Which swing high and low should you use?

There is no single correct swing, so a backtest needs a fixed rule that picks the swing the same way every time. Think of measuring the height of a room when each person chooses where the floor is. Everyone gets a different answer. Two traders looking at the same chart often anchor on different swings. After the fact, the swing that "worked" is easy to find. That makes hand-drawn examples look better than the method really is.

These are common ways to define swings with rules:

MethodRuleSetting to chooseWhen the swing is known
PivotA bar whose high is higher than the N bars on each sideN, for example 3 to 7N bars after the high
Percent zigzagA swing ends when price reverses by X% from its extremeXWhen the X% reversal is reached
Volatility zigzagA swing ends when price reverses by k times the ATR (Average True Range)k and the ATR lengthWhen the reversal is reached
Lookback windowThe highest high and lowest low of the last M barsMAt every bar, but the swing shifts as the window moves

Add a minimum swing size, for example a leg of at least 3 times the ATR. Without it, the rules draw levels on tiny moves where the gap between the levels is smaller than your trading costs.

The last column matters most. Look-ahead bias is the error of using information in a backtest that was not yet available at the time of the trade. It is like betting on a race after you already know the winner. A pivot high with N = 5 only becomes a pivot five bars later. A backtest that draws the levels from the moment of the high uses the future.

With a 5-bar pivot rule, the swing high at bar 10 is only confirmed at bar 15: bars 10 to 15 are a waiting period, and the retracement levels can be used only from bar 15 onward Wait for confirmation 5-bar pivot, high at bar 10 Bar 10 Bar 15 Wait Use levels The high is known 5 bars late. So: draw levels from bar 15 on.
With a 5-bar pivot rule, the swing high at bar 10 is only confirmed at bar 15. A fair backtest can use the levels from bar 15 onward, not earlier.

How do you turn a Fibonacci retracement strategy into testable rules?

A testable strategy states exactly when a setup exists, what triggers the entry, where the stop and target are, and when the setup expires. "Buy near 61.8%" is not a rule, because "near" can mean anything. Here is one complete rule set for a long trade:

  1. Setup: a confirmed swing low L, then a confirmed swing high H, with the leg at least 3 times ATR(20).
  2. Zone: price trades down into the band between the 50% and 61.8% levels.
  3. Trigger: a bar closes back above the 50% level. Enter at the open of the next bar.
  4. Stop: below the 78.6% level, or below L.
  5. Target: a retest of H, or a fixed multiple of the risk.
  6. Expiry: cancel the setup if there is no entry within M bars, if price closes below L, or if a new swing forms.
  7. Costs: commission and slippage on every round trip.

A limit order resting at the 61.8% level is another choice of trigger. A backtest that fills every limit order the moment price touches it is optimistic. In live trading, some of those orders are not filled.

The stop choice changes the trade more than most traders expect.

Hypothetical example

Using the swing from 2,000 to 2,100, the entry fills at 2,052 after a close back above 2,050. With the stop below the swing low at 1,998, the risk is 54 points and the reward to 2,100 is 48 points. The trade must win more than about 53% of the time (54 ÷ 102) just to break even before costs. With the stop at 2,019, below the 78.6% level, the risk is 33 points for the same 48-point reward. The break-even win rate is about 41% (33 ÷ 81), but the stop is hit more often.

Before you run any search, check rule sets like this with the win rate and expectancy calculator. It shows quickly whether a stop and target pair can work at a realistic win rate.

In AlphaPrime (Valynox), strategy generation is where research ideas become testable trading rules, with parameter ranges, entry and exit conditions and search constraints. AlphaPrime's backtesting evaluates each candidate with fees, slippage, next-bar execution and trading sessions. Swing-based rules then get the same treatment as any other rule.

Do Fibonacci levels add anything beyond a normal pullback?

Only a comparison test can show it, because a pullback rule that uses Fibonacci levels may work for reasons that have nothing to do with the ratios. The levels are widely watched, so some traders expect orders to gather around them. But widely watched does not mean useful, and a backtest is the way to check.

Two facts make the levels look stronger on a chart than they are:

  • The levels cover the whole range. The common levels are 23.6%, 38.2%, 50%, 61.8% and 78.6%. The largest gap between two of them is 16.8% of the swing. Any pullback that stops in that range is therefore within 8.4% of the swing from some level. If you allow a small zone around each level, almost every pullback seems to "respect" one.
  • Memory picks the winners. Charts where price turned at 61.8% are memorable. Charts where it went straight through are forgotten.

Run these comparison tests:

  1. Shifted zones. Keep every rule the same, but move the zone to 40–50% or 65–75%.
  2. Plain pullback. Replace the levels with "price pulls back at least 1.5 times ATR from the swing high".
  3. Same exits. Keep the stop, target and expiry identical in every version, so only the entry differs.

Sullivan, Timmermann and White (1999) showed why this matters. When many technical trading rules are tested on the same data, the best one can look good by chance alone. A fair judgment must account for how many rules were tried (White, 2000).

How do you test on out-of-sample data and check nearby settings?

A Fibonacci rule earns trust only when it holds up on data it was not built on and keeps working when its settings move a little. Out-of-sample data is price history that was not used to design or tune the rules. One simple split is to build the rules on the first 70% of your history and leave the last 30% untouched until the rules are final. A walk-forward analysis goes further. It tunes on one window, tests on the next, and repeats across the whole history.

Then test the neighbours of your chosen settings. A strategy that works only at exactly 61.8% is like a key that opens a lock at one exact angle. It is more likely a lucky fit than a real effect. Try these ranges, for example:

  • Lower edge of the zone: 45%, 50%, 55%.
  • Upper edge of the zone: 58%, 61.8%, 65%, 68%.
  • Pivot strength N: 3, 4, 5, 6, 7 bars.
  • Minimum swing size: 2, 3, 4 times the ATR.

You want a plateau: a broad area where results change slowly. A single sharp peak at one setting suggests the search found noise. Bailey, Borwein, López de Prado and Zhu (2014) explain why the best result from many trials tends to be inflated when it is tested on new data. Results for neighbouring retracement settings can sit side by side in AlphaPrime's strategy databank, where searching and sorting show whether a setting sits on a plateau or a lone peak.

Two illustrative result patterns across zone levels from 55% to 68%: on the left results stay similar at every level, a robust plateau; on the right only 61.8% works, a spike that points to a lucky fit Want a plateau, not a peak Result by zone level, illustration Plateau Spike 55% 61.8% 68% 55% 61.8% 68% One sharp peak is likely luck. So: test the nearby settings.
Left: results change slowly as the level moves, which is a robust pattern. Right: only 61.8% works, which points to a lucky fit.

Read the full picture before you decide:

CheckEncouraging signWeak sign
Out-of-sample resultSame direction as in-sample, somewhat smallerCollapses or turns negative
Nearby settingsSimilar results across the rangeOnly one exact setting works
Versus plain pullbackClearly better with identical exitsAbout the same
Trade countDozens of trades in each test windowA handful of trades
CostsAverage trade several times the round-trip costEdge disappears when slippage is doubled

AlphaPrime's strategy validation includes walk-forward analysis and custom thresholds. You can set the out-of-sample standard before you see any results.

What this means if you use AlphaPrime: treat a Fibonacci idea like any other rule set. Fix the swing definition, set parameter ranges and costs, and judge candidates on walk-forward results and neighbouring settings, not on the single best run.

Frequently asked questions

Is 50% a Fibonacci retracement level?

The 50% level is not a Fibonacci ratio. It does not come from dividing numbers in the Fibonacci sequence. Charting tools include it by convention because a half-way pullback is a common reference point. In a backtest, treat it like any other level and test whether it adds anything.

Which Fibonacci retracement level is the most important?

Traders watch the 50% and 61.8% levels most, and many treat the band between them as the main pullback zone. No level is known in advance to work better on every market. Test your zone against shifted zones on your own data before you rely on it.

Should you draw Fibonacci retracement from wicks or closing prices?

Most traders use the extreme high and low, which means the wicks. Closing prices are also valid. What matters is that you choose one and write it into your rules, because a backtest must anchor every swing the same way.

Does a Fibonacci retracement strategy work on futures?

There is no general answer. The result depends on the market, the bar size, the swing rules, the exits and the costs. The way to find out is a backtest with fixed rules, realistic costs, out-of-sample data and a comparison against nearby levels and a plain pullback rule.

What timeframe is best for Fibonacci retracement?

The tool works on any bar size. On shorter bars the swings are smaller, so commission and slippage take a larger share of each trade. Add a minimum swing size so the gap between levels stays well above your round-trip cost.

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.
  • Sullivan, R., Timmermann, A., & White, H. (1999). Data-Snooping, Technical Trading Rule Performance, and the Bootstrap. The Journal of Finance, 54(5), 1647–1691.
  • White, H. (2000). A Reality Check for Data Snooping. Econometrica, 68(5), 1097–1126.