TradingView Pine Script

Here’s a more advanced TradingView Pine Script that combines the following elements:

  • RSI

  • EMA 7

  • EMA 21

  • Pivot Points

  • Smart Money Concepts (SMC)-style Order Blocks (supply/demand zones)

This script is designed to visually highlight confluence areas and possible trade setups aligned with institutional trading logic (SMC).

//@version=5
indicator(“RSI + EMA 7/21 + Pivots + SMC”, overlay=true)

// === INPUTS ===
rsiLen = input.int(14, title=”RSI Length”)
pivotLen = input.int(5, title=”Pivot Point Length”)
orderBlockLookback = input.int(20, title=”Order Block Lookback”)
showRSI = input.bool(true, title=”Show RSI on separate panel”)

// === CALCULATIONS ===
rsi = ta.rsi(close, rsiLen)

ema7 = ta.ema(close, 7)
ema21 = ta.ema(close, 21)

ph = ta.pivothigh(high, pivotLen, pivotLen)
pl = ta.pivotlow(low, pivotLen, pivotLen)

supplyZone = ta.highest(high, orderBlockLookback)
demandZone = ta.lowest(low, orderBlockLookback)

// === CONDITIONS ===
bullishCross = ta.crossover(ema7, ema21)
bearishCross = ta.crossunder(ema7, ema21)

buySignal = rsi < 30 and bullishCross and not na(pl)
sellSignal = rsi > 70 and bearishCross and not na(ph)

// === PLOTS ===
plot(ema7, title=”EMA 7″, color=color.orange)
plot(ema21, title=”EMA 21″, color=color.blue)

plotshape(buySignal, title=”Buy Signal”, location=location.belowbar, color=color.green, style=shape.labelup, text=”BUY”)
plotshape(sellSignal, title=”Sell Signal”, location=location.abovebar, color=color.red, style=shape.labeldown, text=”SELL”)

plot(ph, title=”Pivot High”, color=color.red, linewidth=1, style=plot.style_cross)
plot(pl, title=”Pivot Low”, color=color.green, linewidth=1, style=plot.style_cross)

hline(supplyZone, title=”Supply Zone”, color=color.purple, linestyle=hline.style_dashed)
hline(demandZone, title=”Demand Zone”, color=color.orange, linestyle=hline.style_dashed)

// === RSI Panel (Optional) ===
if showRSI
rsiPlot = rsi
rsiOver = 70
rsiUnder = 30
plot(rsiPlot, title=”RSI”, color=color.gray, display=display.none)
hline(rsiOver, “Overbought”, color=color.red, linestyle=hline.style_dotted)
hline(rsiUnder, “Oversold”, color=color.green, linestyle=hline.style_dotted)

// === ALERT CONDITIONS ===
alertcondition(buySignal, title=”Buy Alert”, message=”Buy Signal: RSI < 30, EMA Crossover & Pivot Low”)
alertcondition(sellSignal, title=”Sell Alert”, message=”Sell Signal: RSI > 70, EMA Crossover & Pivot High”)