P
PipsGrowth

ta Library

Popular technical analysis library with 40+ indicators organized by type (trend, momentum, volatility, volume). Add all indicators to a DataFrame with a single function call.

Difficulty: Beginner
Category: Indicators

Installation

# Pure Python — no compilation needed
$ pip install ta

40+ Indicators by Category

Trend

SMAEMAWMAMACDADXIchimokuAroonCCIDPOKSTTRIXVortex

Momentum

RSIStochasticTSIUOStochRSIWilliams %RAwesome OscillatorKAMAROCPPO

Volatility

Bollinger BandsATRKeltner ChannelDonchian ChannelUlcer Index

Volume

OBVVWAPMFIADICMFEMVForce IndexVPTNVI

Code Examples

Installation

Install ta library

Python
pip install ta
# Verify
python -c "import ta; print('ta library ready!')"

Add All Indicators at Once

The killer feature — add 40+ indicators with one line

Python
import ta
import yfinance as yf
# Get data
df = yf.download("EURUSD=X", period="1y")
# Add ALL indicators with a single line!
df = ta.add_all_ta_features(
df, open="Open", high="High", low="Low",
close="Close", volume="Volume"
)
# Now df has 80+ new columns!
print(f"Total columns: {len(df.columns)}")
print(df.columns.tolist()[:20]) # Preview first 20

Individual Indicators

Calculate specific indicators

Python
import ta
import yfinance as yf
df = yf.download("EURUSD=X", period="1y")
# RSI
df['rsi'] = ta.momentum.RSIIndicator(df['Close'], window=14).rsi()
# MACD
macd = ta.trend.MACD(df['Close'])
df['macd'] = macd.macd()
df['macd_signal'] = macd.macd_signal()
df['macd_hist'] = macd.macd_diff()
# Bollinger Bands
bb = ta.volatility.BollingerBands(df['Close'], window=20, window_dev=2)
df['bb_upper'] = bb.bollinger_hband()
df['bb_lower'] = bb.bollinger_lband()
df['bb_middle'] = bb.bollinger_mavg()
# Stochastic
stoch = ta.momentum.StochasticOscillator(df['High'], df['Low'], df['Close'])
df['stoch_k'] = stoch.stoch()
df['stoch_d'] = stoch.stoch_signal()
print(df[['Close', 'rsi', 'macd', 'bb_upper', 'stoch_k']].tail())

Multi-Factor Strategy

Combine trend, momentum, and volatility

Python
import ta
import yfinance as yf
df = yf.download("EURUSD=X", period="1y")
# Trend indicators
df['sma_20'] = ta.trend.SMAIndicator(df['Close'], window=20).sma_indicator()
df['sma_50'] = ta.trend.SMAIndicator(df['Close'], window=50).sma_indicator()
df['adx'] = ta.trend.ADXIndicator(df['High'], df['Low'], df['Close']).adx()
# Momentum
df['rsi'] = ta.momentum.RSIIndicator(df['Close']).rsi()
# Volatility
df['atr'] = ta.volatility.AverageTrueRange(df['High'], df['Low'], df['Close']).average_true_range()
# Generate signals
latest = df.dropna().iloc[-1]
trend_up = latest['sma_20'] > latest['sma_50']
strong_trend = latest['adx'] > 25
not_overbought = latest['rsi'] < 70
if trend_up and strong_trend and not_overbought:
print("Signal: BUY")
elif not trend_up:
print("Signal: SELL")
else:
print("Signal: HOLD")
print(f"ADX: {latest['adx']:.1f}, RSI: {latest['rsi']:.1f}")

Best Practices

Object-Oriented API

Each indicator is a class — instantiate, then call methods for specific outputs

add_all_ta_features()

Adds all indicators at once — great for ML feature engineering

Column Names

Generated column names can be long — consider renaming for clarity

Volume Required

Some indicators require volume data — ensure your data source provides it

PipsGrowth - Expert Broker Reviews, Trading Strategies & Tools