An RSI gauge chart in Python shows the latest Relative Strength Index reading as a needle on a speedometer-style dial, so you can see at a glance whether a stock or index is oversold, neutral or overbought. In this tutorial we fetch Nifty data with yfinance, calculate RSI(14) with pandas_ta and draw the gauge with Plotly. I have also added an updated 2026 version that works with current yfinance releases and uses Plotly’s built-in gauge indicator.
Key Takeaways
- A gauge chart displays a single value on a fixed scale, which suits bounded indicators like RSI (0 to 100).
- The original tutorial splits RSI into five zones: 0-20 extremely oversold, 20-40 oversold, 40-60 neutral, 60-80 momentum zone, 80-100 extreme overbought.
- The original code draws the dial with a Plotly pie chart (hole=0.5) and a line shape for the needle.
- With yfinance 0.2.48 and later, yf.download returns two-level column names by default, so the original pandas_ta line can return None; the updated version below handles this.
- Plotly’s go.Indicator in “gauge+number” mode gives the same RSI gauge chart in fewer lines.
What Is a Gauge Chart?
In this tutorial, we’ll explore how to visualize the RSI using a gauge chart in Python, leveraging the capabilities of the Plotly library. A “Gauge Chart” visually represents a single value within a given scale, resembling the dashboard gauge of a car. In the context of stock market indicators, such as the Relative Strength Index (RSI), it is used to depict how overbought or oversold a security is. The chart typically has a semicircular scale with a needle or pointer indicating the current value.

RSI Zones Used in the RSI Gauge Chart
In this tutorial, we will be fetching the historical data from yfinance and computing the latest RSI value using the pandas_ta library. We will be creating the gauge chart quadrant values as follows:
| RSI range | Zone | Colour in the gauge |
|---|---|---|
| 0-20 | Extremely Oversold | Dark green (#2bad4e) |
| 20-40 | Over Sold | Light green (#85e043) |
| 40-60 | Neutral | Yellow (#eff229) |
| 60-80 | Momentum Zone | Orange (#f2a529) |
| 80-100 | Extreme Overbought | Red (#f25829) |
Note that this is a momentum-friendly reading of RSI. The classic Wilder levels treat 70 and 30 as overbought and oversold, but in a strong trend Nifty can stay between 60 and 80 for weeks, which is why that band is labelled the momentum zone rather than a sell signal.
Step 1: Import the Libraries and Compute the RSI Value
import yfinance as yf
import pandas as pd
import pandas_ta as ta
import plotly.graph_objects as go
import numpy as np
# Fetch data from Yahoo Finance
ticker = "^NSEI" # Example ticker
data = yf.download(ticker, start="2023-01-01", end="2024-01-12")
# Calculate RSI using pandas_ta
data['RSI'] = ta.rsi(data['Close'], length=14)
# Latest RSI value
latest_rsi = data['RSI'].iloc[-1]
Step 2: Plot the RSI Gauge Chart in Python
For the visual representation, we’ll create a gauge chart using plotly.graph_objects. This type of chart will allow us to illustrate the RSI level like a car’s speedometer.
The below code snippet sets up the quadrant, colors, and text for the different RSI levels and calculates the angle of the needle based on the latest RSI value.
# Gauge chart setup
plot_bgcolor = "#def"
quadrant_colors = [plot_bgcolor, "#f25829", "#f2a529", "#eff229", "#85e043", "#2bad4e"]
quadrant_text = ["", "<b>Extreme Overbought</b>", "<b>Momentum Zone</b>", "<b>Neutral</b>", "<b>Over Sold</b>", "<b>Extremely Oversold</b>"]
n_quadrants = len(quadrant_colors) - 1
min_value = 0
max_value = 100 # RSI ranges from 0 to 100
hand_length = np.sqrt(2) / 4
hand_angle = 360 * (-latest_rsi/2 - min_value) / (max_value - min_value) - 180
# Create gauge chart
fig = go.Figure(
data=[
go.Pie(
values=[0.5] + (np.ones(n_quadrants) / 2 / n_quadrants).tolist(),
rotation=90,
hole=0.5,
marker_colors=quadrant_colors,
text=quadrant_text,
textinfo="text",
hoverinfo="skip",
sort=False
),
],
layout=go.Layout(
showlegend=False,
margin=dict(b=0,t=10,l=10,r=10),
width=800,
height=800,
paper_bgcolor=plot_bgcolor,
annotations=[
go.layout.Annotation(
text=f"<b>Nifty RSI Level:</b><br>{latest_rsi:.2f}",
x=0.5, xanchor="center", xref="paper",
y=0.25, yanchor="bottom", yref="paper",
showarrow=False,
font=dict(size=14)
)
],
shapes=[
go.layout.Shape(
type="circle",
x0=0.48, x1=0.52,
y0=0.48, y1=0.52,
fillcolor="#333",
line_color="#333",
),
go.layout.Shape(
type="line",
x0=0.5, x1=0.5 + hand_length * np.cos(np.radians(hand_angle)),
y0=0.5, y1=0.5 + hand_length * np.sin(np.radians(hand_angle)),
line=dict(color="#333", width=4)
)
]
)
)
fig.show()
How the Needle Angle Is Calculated
The pie chart has six slices. The first slice takes half the circle and uses the background colour, so it is invisible, and the five coloured slices share the other half to form the dial, running from extremely oversold on the left, over the top, to extreme overbought on the right. The formula 360 * (-latest_rsi/2) / 100 - 180 converts an RSI value into an angle on that half circle: RSI 0 gives -180 degrees (pointing left), RSI 50 gives -270 degrees (straight up) and RSI 100 gives -360 degrees (pointing right). The needle is then drawn as a line from the centre (0.5, 0.5) using the cosine and sine of that angle. I checked this by plotting RSI 15, and the needle lands in the dark green extremely oversold zone as expected.
Updated Version (2026): Works With Current yfinance and Uses go.Indicator
When I ran the original Step 1 code in November 2026 with yfinance 1.8, yf.download returned two-level column names such as ('Close', '^NSEI'), so data['Close'] was a DataFrame and ta.rsi() returned None. The version below fixes that with multi_level_index=False, calculates Wilder’s RSI directly in pandas (it matched pandas_ta’s value to the last decimal in my test) and draws the dial with Plotly’s native gauge indicator (Plotly gauge chart documentation), keeping the same five colour zones.
import yfinance as yf
import plotly.graph_objects as go
# Fetch about one year of daily Nifty 50 data.
# multi_level_index=False keeps simple column names (Open, High, Low, Close, Volume)
# in yfinance 0.2.48 and later, where download() returns two-level columns by default.
ticker = "^NSEI"
data = yf.download(ticker, period="1y", interval="1d",
auto_adjust=True, multi_level_index=False, progress=False)
# Wilder's RSI(14) in plain pandas (same smoothing as pandas_ta, AmiBroker and TradingView)
def rsi(close, length=14):
delta = close.diff()
gain = delta.clip(lower=0).ewm(alpha=1/length, min_periods=length, adjust=False).mean()
loss = (-delta.clip(upper=0)).ewm(alpha=1/length, min_periods=length, adjust=False).mean()
return 100 - 100 / (1 + gain / loss)
data["RSI"] = rsi(data["Close"], 14)
latest_rsi = float(data["RSI"].iloc[-1])
last_date = data.index[-1].strftime("%d-%b-%Y")
# Same five zones as the original tutorial
zones = [
(0, 20, "#2bad4e"), # Extremely Oversold
(20, 40, "#85e043"), # Over Sold
(40, 60, "#eff229"), # Neutral
(60, 80, "#f2a529"), # Momentum Zone
(80, 100, "#f25829"), # Extreme Overbought
]
fig = go.Figure(go.Indicator(
mode="gauge+number",
value=latest_rsi,
number={"valueformat": ".2f"},
title={"text": f"Nifty RSI(14) on {last_date}"},
gauge={
"axis": {"range": [0, 100], "tickvals": [0, 20, 40, 60, 80, 100]},
"bar": {"color": "#333333", "thickness": 0.25},
"steps": [{"range": [lo, hi], "color": c} for lo, hi, c in zones],
"threshold": {"line": {"color": "black", "width": 4},
"thickness": 0.9, "value": latest_rsi},
},
))
fig.update_layout(width=700, height=450, margin=dict(t=80, b=20, l=30, r=30))
fig.show()
print(f"{last_date}: RSI(14) = {latest_rsi:.2f}")
On the close of 9 November 2026 this printed an RSI(14) of 78.66 for Nifty, which sits at the top end of the momentum zone on the gauge. Run it after market hours to get the latest daily reading.
Ideas to Extend the RSI Gauge Chart
- Multiple gauges: use
plotly.subplots.make_subplotswith indicator subplots to show RSI for Nifty, Bank Nifty and a few stocks side by side. - Other bounded indicators: the same layout works for Stochastic, MFI, Williams %R (shifted to 0-100) or a market breadth percentage.
- Dashboard: place the gauge in a Streamlit or Flask page, as in my VectorBT Streamlit backtesting app.
- More indicators: for plotting indicators on price charts, see using Plotly and pandas_ta to plot technical indicators.
Common Mistakes
- Too little data: RSI(14) with Wilder smoothing needs well over 14 bars to settle. Download at least a few months of history.
- Intraday partial bars: running the script during market hours uses an incomplete daily candle, so the reading will change by the close.
- Reading the gauge as a signal by itself: a high RSI in an uptrend often means strength, not an immediate reversal. Use it alongside trend and price structure.
This visual tool can be particularly useful when presenting market data, offering a clear and immediate interpretation of the market’s momentum. By following this tutorial, you’ve learned how to fetch market data, calculate RSI, and create a dynamic gauge chart to visualize market strength. Happy trading, and may your analysis be as sharp as your visualizations!
Frequently Asked Questions
How do I make a gauge chart in Python?
The simplest way is Plotly’s go.Indicator with mode=”gauge+number”. Set the axis range, add coloured steps for each zone and pass the value you want to display.
How do I add a needle to a Plotly gauge chart?
Plotly’s indicator draws a bar rather than a needle. For a needle, draw a line shape from the centre at an angle calculated from the value, as the original code in this tutorial does with a pie-chart dial.
Which RSI period should I use for the gauge?
RSI(14) is the standard. Shorter periods such as RSI(2) or RSI(5) move between extremes much faster and suit short-term mean reversion setups.
Why does ta.rsi return None with yfinance data?
Newer yfinance versions return multi-level columns, so data[“Close”] is a DataFrame instead of a Series. Pass multi_level_index=False to yf.download or select the ticker column first.
Learn by watching: free videos every week
Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

