Fibonacci retracement strategy (levels, rules and code)

Fibonacci retracement takes a price swing and draws horizontal levels at 23.6%, 38.2%, 50%, 61.8% and 78.6% of it — the idea being that pullbacks in a trend tend to pause and reverse at these ratios before the trend resumes. It's one of the most popular and most argued-about tools in trading. Skeptics call it numerology; users counter that it works partly because so many traders watch the same levels. This guide gives the levels, the rules, the code, and an honest take on the debate.

On this page
  1. The levels
  2. Trading the pullback
  3. The code
  4. Confluence
  5. Numerology or self-fulfilling?
  6. Sizing & risk
  7. FAQ

The levels and where they come from

The ratios derive from the Fibonacci sequence: 0.618 (the golden ratio) is any number divided by the next; 0.382 is a number divided by the one two places along; 0.236 is three places. The 50% level isn't a true Fibonacci number but is included by convention (it's the halfway pullback). You anchor the tool from a swing low to a swing high (or vice versa), and the levels appear in between.

Trading the retracement

0% 38.2 50 61.8 100% buy 61.8% pullback
Price rallies, pulls back to the 61.8% level, then resumes — the classic Fibonacci long.

The code

python · fib_levels.pydef fib_levels(swing_low, swing_high):
    rng = swing_high - swing_low
    ratios = [0.236, 0.382, 0.5, 0.618, 0.786]
    return {r: swing_high - rng*r for r in ratios}

levels = fib_levels(swing_low, swing_high)
# buy zone = a tag of the 0.618 level in an uptrend, with a reversal trigger
if abs(price - levels[0.618]) / price < 0.004 and reversal_bar:
    signal = 'buy'

Confluence is what makes it tradeable

A Fibonacci level alone is a line on a chart. It becomes a real edge when it lines up with something else — a prior support, a moving average, a round number, or a trendline. That stack of reasons is called confluence, and a 61.8% retracement sitting on the 200-EMA is far more respected than 61.8% by itself.

Numerology, or self-fulfilling prophecy?

It works partly because everyone watches it

There's no proven physical reason markets “must” respect 61.8%. The honest view: Fibonacci has reflexive power because so many traders place orders at the same levels, which can make those levels act as support/resistance. Treat it as a zone for entries with confirmation, never a precise price you blindly trust — and always backtest it.

Sizing and risk

Put your stop just beyond the next Fibonacci level (e.g. below 78.6% if you bought 61.8%) so a failed retracement is a small, defined loss, and size from it with the position calculator. Because Fibonacci is discretionary, it's easy to fool yourself drawing levels in hindsight — codify exact swing-detection rules and test them in the backtester before trusting any of it.

Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

What is a Fibonacci retracement strategy?

It draws horizontal levels at 23.6%, 38.2%, 50%, 61.8% and 78.6% of a price swing and trades pullbacks: in an uptrend you buy as price retraces to a level like 61.8% and shows a reversal, expecting the trend to resume. It is a pullback-entry tool, not a standalone system.

Which Fibonacci level is most important?

The 61.8% level (the golden ratio) and 38.2% are the most-watched, with 50% used by convention. 61.8% is often considered the strongest retracement zone, especially when it lines up with other support or resistance — that overlap, called confluence, is what makes a level tradeable.

Does Fibonacci retracement actually work?

There is no proven physical reason markets must respect Fibonacci ratios. Many traders consider it a self-fulfilling tool: it can act as support or resistance because so many participants place orders at the same levels. Used as a zone with confirmation and backtesting, it can add an edge.

How do you set a stop with Fibonacci?

Place the stop just beyond the next Fibonacci level below your entry — for example, if you buy the 61.8% retracement, set the stop below the 78.6% level. A break of that level invalidates the retracement thesis, keeping the loss small and defined.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.