All free tools

Momentum indicator

RSI Calculator

Work out the Relative Strength Index for a single point from the average gain and average loss over your lookback period. More useful than the number, though, is understanding what RSI actually measures.

RSI
60.00
Between 30 and 70, the neutral zone.
Relative Strength (RS)
1.500
Average gain divided by average loss.

What the RSI is

The Relative Strength Index, developed by J. Welles Wilder and introduced in 1978, is a momentum oscillator that measures the speed and size of recent price changes on a bounded scale from 0 to 100. It is designed to answer a single question: over the lookback window, how much of the total movement has been to the upside versus the downside?

The calculation begins by separating each bar's change from the previous close into a gain (upward moves) or a loss (downward moves, taken as a positive number). Wilder's smoothed average of the gains and of the losses over the period gives the relative strength, RS = average gain / average loss. RSI is then RSI = 100 − 100 / (1 + RS). When there are no losses in the window, RSI is defined as 100. The default lookback is 14 periods, the value Wilder originally proposed.

Why the RSI is used

RSI is one of the most widely watched momentum tools because it compresses a messy price history into a single, easy-to-read number. Readings are traditionally described as overbought above 70 and oversold below 30, though these are long-standing conventions rather than rules, and many analysts shift them in strongly trending markets where an instrument can stay overbought or oversold for a long time.

Beyond the raw level, a common area of study is RSI divergence, where price makes a new high or low that the oscillator does not confirm, and the midline near 50, which some treat as a rough gauge of whether momentum leans up or down. What any of these observations mean, and whether they matter to you, is entirely a matter of your own analysis.

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

This calculator gives you RSI at one moment. On a live TradingView chart you would want it recalculated on every bar and plotted beneath price. In Pine Script that is a single call, ta.rsi(close, 14), but wiring it into a full indicator with overbought and oversold lines, alerts, or entry logic is where most of the work lives.

Pine Script v6
//@version=6
indicator("RSI", overlay=false)

length = input.int(14, "RSI Length")
rsiValue = ta.rsi(close, length)

plot(rsiValue, "RSI", color=color.purple)
hline(70, "Overbought")
hline(30, "Oversold")

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.