All free tools

Price levels

Fibonacci Retracement Calculator

Enter a swing high and swing low to compute the classic Fibonacci retracement levels and the common extensions beyond the move. The concept, applying Fibonacci ratios to a price swing, is what matters most.

Direction of the move
LevelTypePrice
0.0%Retracement113.20
23.6%Retracement110.08
38.2%Retracement108.16
50.0%Retracement106.60
61.8%Retracement105.04
78.6%Retracement102.82
100.0%Retracement100.00
127.2%Extension96.41
161.8%Extension91.84
261.8%Extension78.64

What Fibonacci retracements are

Fibonacci retracement levels come from the Fibonacci sequence, where each number is the sum of the two before it. As the sequence grows, the ratio of consecutive numbers approaches 0.618, and related ratios such as 0.382 and 0.236 fall out of the same relationships. Technical analysts apply these ratios to the distance a price has traveled between a significant low and high.

The calculation is straightforward. Take the vertical distance between the swing high and the swing low, the range, and place levels at set percentages of that range. In an uptrend the 0% level sits at the high and the 100% level at the low, so a 38.2% retracement is the high minus 38.2% of the range. In a downtrend the levels are mirrored, measured up from the low. The 50% level is not a true Fibonacci ratio but is included by convention. Extension levels beyond 100%, such as 127.2% and 161.8%, project past the original move.

Why Fibonacci levels are used

Fibonacci retracements are among the most widely drawn tools in technical analysis. After a strong move, analysts plot the levels between the swing low and high to identify areas where price paused, reversed, or continued in the past. The 61.8% and 38.2% levels attract particular attention, and extensions are used to frame potential targets.

It is worth remembering that these are geometric reference levels, not predictions. Whether price respects a level, and what you do with that information, is entirely your own judgment.

What are TradingView and Pine Script?

TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.

People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.

The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.

Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.

Turn this into Pine Script

Here you calculated one static set of levels. On a chart you would usually want them drawn as horizontal lines that extend to the right and update as you pick new swing points. In Pine Script that means computing each level from the range and drawing it with line.new or box.new, plus the logic to detect or accept the swing high and low, which is where most of the effort goes.

Pine Script v6
//@version=6
indicator("Fib Levels", overlay=true)

swingHigh = input.price(0.0, "Swing High", confirm=true)
swingLow  = input.price(0.0, "Swing Low", confirm=true)

range = swingHigh - swingLow
level = (ratio) => swingHigh - ratio * range

line.new(bar_index - 50, level(0.382), bar_index, level(0.382), color=color.blue, extend=extend.right)
line.new(bar_index - 50, level(0.5),   bar_index, level(0.5),   color=color.gray, extend=extend.right)
line.new(bar_index - 50, level(0.618), bar_index, level(0.618), color=color.blue, extend=extend.right)

PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v5 or v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.

Related free calculators

From the blog

PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.