RSI Pine Script Strategy for TradingView

Josh Miller
A simple RSI strategy written in PineScript. Copy and paste into TradingView. Buys when oversold, sells when overbought.
rsi pinescript strategy

A simple RSI pine script strategy. Copy and paste into TradingView. Or if you want to backtest and run the bot live.

How the strategy works

  • Buys as RSI crosses over overbought (30)
  • Sells as RSI crosses under oversold (70)

RSI Pine Script Strategy

// This source code is subject to the terms of the Mozilla Public License 2.0 at

strategy("RSI Strategy")

RSI = rsi(close, 14)
oversold = 30
overbought = 70


strategy.order("Long", long=true, when=crossunder(RSI, oversold))
strategy.order("Short", long=false, when=crossover(RSI, overbought))


What is the RSI?

The Relative Strength Index (RSI) is one of the most popular technical indicators in use today. It is used to gauge a stock’s momentum, or its ability to move up or down. The RSI is a momentum indicator that compares upward and downward movements over time. The RSI is expressed as a weighted average of these upward and downward movements, where the most recent price movement accounts for more of the weighting than past movements.

Who made the RSI?

The RSI was developed by J. Welles Wilder in an article entitled “New Concepts in Technical Trading Systems.” He published the first table of indicators with values ranging from 0 to 100 in the September 1978 issue of Commodities magazine. Wilder originally intended the RSI to be used exclusively on daily charts; however, it can be applied to weekly and intra-day charts just as easily as it can be applied to daily charts.

See also  MACD PineScript Strategy for TradingView

How does the RSI work?

The basic premise behind the RSI is that positive and negative price swings will naturally ebb and flow over time. By keeping track of these swings and weighing them according to their recency, the RSI is able to show whether positive or negative changes are currently more dominant. The resulting indicator fluctuates between 0 and 100, with readings above 70 representing overbought conditions, and readings under 30 representing oversold conditions.

Previous Post

DEX Aggregators: 6 Places to Trade with the best routing

Next Post
macd 200 ema strategy

MACD 200 EMA Pine Script Strategy

Related Posts