OPEN-SOURCE SCRIPT
ScalpZone — EMA+RSI+ATR (Nifty/Sensex)

//version=5
indicator("ScalpZone — EMA+RSI+ATR (Nifty/Sensex)", overlay=true, shorttitle="ScalpZone v2")
// === Inputs ===
fastLen = input.int(9, title="Fast EMA", minval=1)
slowLen = input.int(21, title="Slow EMA", minval=1)
rsiLen = input.int(7, title="RSI Length", minval=1)
rsi_high = input.int(70, title="RSI Overbought")
rsi_low = input.int(35, title="RSI Oversold (for entries)")
atrLen = input.int(14, title="ATR Length")
atrMult = input.float(1.5, title="ATR Multiplier (trailing stop)")
useStrictPullback = input.bool(true, title="Require pullback candle (close < fast EMA) for entry")
showStops = input.bool(true, title="Show trailing stop line")
showEMAs = input.bool(true, title="Show EMAs")
// === Core indicators ===
emaFast = ta.ema(close, fastLen)
emaSlow = ta.ema(close, slowLen)
rsiVal = ta.rsi(close, rsiLen)
atr = ta.atr(atrLen)
// === Trend detection ===
bullTrend = emaFast > emaSlow
bearTrend = emaFast < emaSlow
// Pullback
pullback = close < emaFast
// Entry conditions
longCondition = bullTrend and (not useStrictPullback or pullback) and (rsiVal > rsi_low and rsiVal < rsi_high) and close > open and close > emaFast
shortCondition = bearTrend and (not useStrictPullback or not pullback) and (rsiVal < rsi_high and rsiVal > rsi_low) and close < open and close < emaFast
// === Trailing stops ===
var float longTrail = na
var float shortTrail = na
if (longCondition)
longTrail := close - atr * atrMult
else if not na(longTrail)
longTrail := math.max(longTrail, close - atr * atrMult)
if (shortCondition)
shortTrail := close + atr * atrMult
else if not na(shortTrail)
shortTrail := math.min(shortTrail, close + atr * atrMult)
// Exit signals
longExit = not na(longTrail) and close < longTrail
shortExit = not na(shortTrail) and close > shortTrail
// === Dynamic EMA colors ===
emaFastColor = emaFast > emaSlow ? color.green : color.red
emaSlowColor = color.orange
// === Plots ===
// Signals
plotshape(longCondition, title="Long Entry", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.tiny, text="LONG")
plotshape(shortCondition, title="Short Entry", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.tiny, text="SHORT")
plotshape(longExit, title="Long Exit", location=location.abovebar, color=color.orange, style=shape.xcross, size=size.tiny, text="EXIT")
plotshape(shortExit, title="Short Exit", location=location.belowbar, color=color.orange, style=shape.xcross, size=size.tiny, text="EXIT")
// EMAs (with visibility toggle)
plot(emaFast, title="EMA Fast", color=emaFastColor, linewidth=2,
display = showEMAs ? display.all : display.none)
plot(emaSlow, title="EMA Slow", color=emaSlowColor, linewidth=2,
display = showEMAs ? display.all : display.none)
// Trailing stops (with visibility toggle)
plot(longTrail, title="Long Trail", style=plot.style_linebr, linewidth=2, color=color.green,
display = showStops ? display.all : display.none)
plot(shortTrail, title="Short Trail", style=plot.style_linebr, linewidth=2, color=color.red,
display = showStops ? display.all : display.none)
// RSI (hidden panel — you can enable in Style menu)
plot(rsiVal, title="RSI", color=color.blue, display=display.none)
hline(rsi_high, "RSI High", color=color.gray, linestyle=hline.style_dotted)
hline(rsi_low, "RSI Low", color=color.gray, linestyle=hline.style_dotted)
// === Alerts ===
alertcondition(longCondition, title="ScalpZone Long", message="ScalpZone: LONG signal on {{ticker}} {{interval}} — Close: {{close}}")
alertcondition(shortCondition, title="ScalpZone Short", message="ScalpZone: SHORT signal on {{ticker}} {{interval}} — Close: {{close}}")
alertcondition(longExit, title="ScalpZone Long Exit", message="ScalpZone: EXIT LONG on {{ticker}} {{interval}} — Close: {{close}}")
alertcondition(shortExit, title="ScalpZone Short Exit", message="ScalpZone: EXIT SHORT on {{ticker}} {{interval}} — Close: {{close}}")
indicator("ScalpZone — EMA+RSI+ATR (Nifty/Sensex)", overlay=true, shorttitle="ScalpZone v2")
// === Inputs ===
fastLen = input.int(9, title="Fast EMA", minval=1)
slowLen = input.int(21, title="Slow EMA", minval=1)
rsiLen = input.int(7, title="RSI Length", minval=1)
rsi_high = input.int(70, title="RSI Overbought")
rsi_low = input.int(35, title="RSI Oversold (for entries)")
atrLen = input.int(14, title="ATR Length")
atrMult = input.float(1.5, title="ATR Multiplier (trailing stop)")
useStrictPullback = input.bool(true, title="Require pullback candle (close < fast EMA) for entry")
showStops = input.bool(true, title="Show trailing stop line")
showEMAs = input.bool(true, title="Show EMAs")
// === Core indicators ===
emaFast = ta.ema(close, fastLen)
emaSlow = ta.ema(close, slowLen)
rsiVal = ta.rsi(close, rsiLen)
atr = ta.atr(atrLen)
// === Trend detection ===
bullTrend = emaFast > emaSlow
bearTrend = emaFast < emaSlow
// Pullback
pullback = close < emaFast
// Entry conditions
longCondition = bullTrend and (not useStrictPullback or pullback) and (rsiVal > rsi_low and rsiVal < rsi_high) and close > open and close > emaFast
shortCondition = bearTrend and (not useStrictPullback or not pullback) and (rsiVal < rsi_high and rsiVal > rsi_low) and close < open and close < emaFast
// === Trailing stops ===
var float longTrail = na
var float shortTrail = na
if (longCondition)
longTrail := close - atr * atrMult
else if not na(longTrail)
longTrail := math.max(longTrail, close - atr * atrMult)
if (shortCondition)
shortTrail := close + atr * atrMult
else if not na(shortTrail)
shortTrail := math.min(shortTrail, close + atr * atrMult)
// Exit signals
longExit = not na(longTrail) and close < longTrail
shortExit = not na(shortTrail) and close > shortTrail
// === Dynamic EMA colors ===
emaFastColor = emaFast > emaSlow ? color.green : color.red
emaSlowColor = color.orange
// === Plots ===
// Signals
plotshape(longCondition, title="Long Entry", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.tiny, text="LONG")
plotshape(shortCondition, title="Short Entry", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.tiny, text="SHORT")
plotshape(longExit, title="Long Exit", location=location.abovebar, color=color.orange, style=shape.xcross, size=size.tiny, text="EXIT")
plotshape(shortExit, title="Short Exit", location=location.belowbar, color=color.orange, style=shape.xcross, size=size.tiny, text="EXIT")
// EMAs (with visibility toggle)
plot(emaFast, title="EMA Fast", color=emaFastColor, linewidth=2,
display = showEMAs ? display.all : display.none)
plot(emaSlow, title="EMA Slow", color=emaSlowColor, linewidth=2,
display = showEMAs ? display.all : display.none)
// Trailing stops (with visibility toggle)
plot(longTrail, title="Long Trail", style=plot.style_linebr, linewidth=2, color=color.green,
display = showStops ? display.all : display.none)
plot(shortTrail, title="Short Trail", style=plot.style_linebr, linewidth=2, color=color.red,
display = showStops ? display.all : display.none)
// RSI (hidden panel — you can enable in Style menu)
plot(rsiVal, title="RSI", color=color.blue, display=display.none)
hline(rsi_high, "RSI High", color=color.gray, linestyle=hline.style_dotted)
hline(rsi_low, "RSI Low", color=color.gray, linestyle=hline.style_dotted)
// === Alerts ===
alertcondition(longCondition, title="ScalpZone Long", message="ScalpZone: LONG signal on {{ticker}} {{interval}} — Close: {{close}}")
alertcondition(shortCondition, title="ScalpZone Short", message="ScalpZone: SHORT signal on {{ticker}} {{interval}} — Close: {{close}}")
alertcondition(longExit, title="ScalpZone Long Exit", message="ScalpZone: EXIT LONG on {{ticker}} {{interval}} — Close: {{close}}")
alertcondition(shortExit, title="ScalpZone Short Exit", message="ScalpZone: EXIT SHORT on {{ticker}} {{interval}} — Close: {{close}}")
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.