Top 5 Trading Indicators for Market Analysis

Trading indicators are essential for analyzing the market trend, deciding entry/exit points, and optimizing trading plans. I have personally used many of these strategies. Today, I will present the best 5 trading indicators used by professional traders and their Pine Script codes so that you can implement them easily in TradingView.


1. Moving Average (MA) – Trend-Following Indicator

What It Does: Smooths price data to identify trends.

  • Simple Moving Average (SMA) – Equal weight to all prices.
  • Exponential Moving Average (EMA) – More weight to recent prices.

Pine Script Code (EMA & SMA Crossover Strategy)

//@version=5
strategy("MA Crossover Strategy", overlay=true)

// Inputs
fastLength = input(9, title="Fast MA Length")
slowLength = input(21, title="Slow MA Length")

// Calculate MAs
fastMA = ta.ema(close, fastLength)
slowMA = ta.ema(close, slowLength)

// Plot MAs
plot(fastMA, color=color.blue, title="Fast MA")
plot(slowMA, color=color.red, title="Slow MA")

// Crossover Signals
longCondition = ta.crossover(fastMA, slowMA)
shortCondition = ta.crossunder(fastMA, slowMA)

// Execute Trades
if (longCondition)
    strategy.entry("Buy", strategy.long)
if (shortCondition)
    strategy.entry("Sell", strategy.short)

2. Relative Strength Index (RSI) – Momentum Oscillator

What It Does: Measures overbought (70+) and oversold (30-) conditions.

Pine Script Code (RSI Strategy)

//@version=5
strategy("RSI Strategy", overlay=true)

// Inputs
rsiLength = input(14, title="RSI Length")
overbought = input(70, title="Overbought Level")
oversold = input(30, title="Oversold Level")

// Calculate RSI
rsiValue = ta.rsi(close, rsiLength)

// Plot RSI
plot(rsiValue, title="RSI", color=color.purple)
hline(overbought, "Overbought", color=color.red)
hline(oversold, "Oversold", color=color.green)

// Trading Signals
if (ta.crossunder(rsiValue, overbought))
    strategy.close("Buy", comment="Sell Signal")
if (ta.crossover(rsiValue, oversold))
    strategy.entry("Buy", strategy.long)

3. Bollinger Bands® – Volatility Indicator

What It Does: Shows price volatility and potential reversals.

Pine Script Code (Bollinger Bands Strategy)

//@version=5
strategy("Bollinger Bands Strategy", overlay=true)

// Inputs
length = input(20, title="BB Length")
mult = input(2.0, title="Standard Deviation")

// Calculate Bollinger Bands
basis = ta.sma(close, length)
upper = basis + mult * ta.stdev(close, length)
lower = basis - mult * ta.stdev(close, length)

// Plot Bands
plot(basis, "Basis", color=color.blue)
plot(upper, "Upper Band", color=color.red)
plot(lower, "Lower Band", color=color.green)

// Trading Signals
longCondition = ta.crossover(close, lower)
shortCondition = ta.crossunder(close, upper)

if (longCondition)
    strategy.entry("Buy", strategy.long)
if (shortCondition)
    strategy.entry("Sell", strategy.short)

4. MACD (Moving Average Convergence Divergence) – Trend & Momentum

What It Does: Combines trend-following and momentum.

Pine Script Code (MACD Strategy)

//@version=5
strategy("MACD Strategy", overlay=true)

// Inputs
fastLen = input(12, title="Fast Length")
slowLen = input(26, title="Slow Length")
signalLen = input(9, title="Signal Length")

// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, fastLen, slowLen, signalLen)

// Plot MACD
plot(macdLine, "MACD", color=color.blue)
plot(signalLine, "Signal", color=color.red)

// Trading Signals
longCondition = ta.crossover(macdLine, signalLine)
shortCondition = ta.crossunder(macdLine, signalLine)

if (longCondition)
    strategy.entry("Buy", strategy.long)
if (shortCondition)
    strategy.entry("Sell", strategy.short)

5. Stochastic Oscillator – Momentum Indicator

What It Does: Identifies overbought/oversold zones.

Pine Script Code (Stochastic Strategy)

//@version=5
strategy("Stochastic Strategy", overlay=true)

// Inputs
kLength = input(14, title="%K Length")
dLength = input(3, title="%D Length")
overbought = input(80, title="Overbought Level")
oversold = input(20, title="Oversold Level")

// Calculate Stochastic
k = ta.sma(ta.stoch(close, high, low, kLength), dLength)
d = ta.sma(k, dLength)

// Plot Stochastic
plot(k, "%K", color=color.blue)
plot(d, "%D", color=color.red)
hline(overbought, "Overbought", color=color.red)
hline(oversold, "Oversold", color=color.green)

// Trading Signals
longCondition = ta.crossover(k, oversold)
shortCondition = ta.crossunder(k, overbought)

if (longCondition)
    strategy.entry("Buy", strategy.long)
if (shortCondition)
    strategy.entry("Sell", strategy.short)

Final Thoughts

These 5 trading indicators (MA, RSI, Bollinger Bands, MACD, Stochastic) are powerful tools for traders. By using the provided Pine Script codes, you can backtest and automate these strategies in TradingView.