PROTECTED SOURCE SCRIPT
EMRVA (2)

//version=5
indicator("EMRVA2)", overlay=true)
// === Inputs ===
emaLen = input.int(200, "EMA Length")
emaFilter = input.int(200, "Trend EMA Filter")
rsiLen = input.int(14, "RSI Length")
volLen = input.int(20, "Volume MA Length")
bodyLen = input.int(14, "Body SMA Length")
minBars = input.int(10, "Min Bars Before New Signal")
atrMult = input.float(0.5, "ATR Body Filter")
spikeATR = input.float(3.0, "Ignore if candle > ATR ×")
// === Heikin Ashi ===
haClose = (open + high + low + close) / 4.0
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2.0 : (haOpen[1] + haClose[1]) / 2.0
haHigh = math.max(high, math.max(haClose, haOpen))
haLow = math.min(low, math.min(haClose, haOpen))
// === MAs ===
ema21 = ta.ema(haClose, emaLen)
ema200 = ta.ema(haClose, emaFilter)
plot(ema21, color=color.orange, linewidth=2, title="EMA21")
plot(ema200, color=color.blue, linewidth=2, title="EMA200")
// === Indicators ===
macdLine = ta.ema(haClose, 12) - ta.ema(haClose, 26)
signalLine = ta.ema(macdLine, 9)
rsi = ta.rsi(haClose, rsiLen)
volMA = ta.sma(volume, volLen)
volCond = volume > volMA
bodySize = math.abs(haClose - haOpen)
avgBody = ta.sma(bodySize, bodyLen)
atr = ta.atr(14)
candleRange = high - low
// === فلتر الشمعة غير الطبيعية ===
isSpike = candleRange > atr * spikeATR
// === Conditions ===
longCond = haClose > ema21 and macdLine > signalLine and rsi > 50 and volCond and haClose > haOpen
shortCond = haClose < ema21 and macdLine < signalLine and rsi < 50 and volCond and haClose < haOpen
// === Filters ===
longCond := longCond and haClose > ema200 and bodySize > atr * atrMult and not isSpike
shortCond := shortCond and haClose < ema200 and bodySize > atr * atrMult and not isSpike
// === Signal management ===
var int lastSignalBar = na
var int lastSignalType = 0 // 0=none, 1=buy, -1=sell
enoughBars = na(lastSignalBar) or (bar_index - lastSignalBar >= minBars)
canBuy = longCond and enoughBars and (lastSignalType != 1)
canSell = shortCond and enoughBars and (lastSignalType != -1)
buySignal = canBuy
sellSignal = canSell
if buySignal
lastSignalBar := bar_index
lastSignalType := 1
if sellSignal
lastSignalBar := bar_index
lastSignalType := -1
plotshape(buySignal, title="BUY", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="SELL", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
indicator("EMRVA2)", overlay=true)
// === Inputs ===
emaLen = input.int(200, "EMA Length")
emaFilter = input.int(200, "Trend EMA Filter")
rsiLen = input.int(14, "RSI Length")
volLen = input.int(20, "Volume MA Length")
bodyLen = input.int(14, "Body SMA Length")
minBars = input.int(10, "Min Bars Before New Signal")
atrMult = input.float(0.5, "ATR Body Filter")
spikeATR = input.float(3.0, "Ignore if candle > ATR ×")
// === Heikin Ashi ===
haClose = (open + high + low + close) / 4.0
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2.0 : (haOpen[1] + haClose[1]) / 2.0
haHigh = math.max(high, math.max(haClose, haOpen))
haLow = math.min(low, math.min(haClose, haOpen))
// === MAs ===
ema21 = ta.ema(haClose, emaLen)
ema200 = ta.ema(haClose, emaFilter)
plot(ema21, color=color.orange, linewidth=2, title="EMA21")
plot(ema200, color=color.blue, linewidth=2, title="EMA200")
// === Indicators ===
macdLine = ta.ema(haClose, 12) - ta.ema(haClose, 26)
signalLine = ta.ema(macdLine, 9)
rsi = ta.rsi(haClose, rsiLen)
volMA = ta.sma(volume, volLen)
volCond = volume > volMA
bodySize = math.abs(haClose - haOpen)
avgBody = ta.sma(bodySize, bodyLen)
atr = ta.atr(14)
candleRange = high - low
// === فلتر الشمعة غير الطبيعية ===
isSpike = candleRange > atr * spikeATR
// === Conditions ===
longCond = haClose > ema21 and macdLine > signalLine and rsi > 50 and volCond and haClose > haOpen
shortCond = haClose < ema21 and macdLine < signalLine and rsi < 50 and volCond and haClose < haOpen
// === Filters ===
longCond := longCond and haClose > ema200 and bodySize > atr * atrMult and not isSpike
shortCond := shortCond and haClose < ema200 and bodySize > atr * atrMult and not isSpike
// === Signal management ===
var int lastSignalBar = na
var int lastSignalType = 0 // 0=none, 1=buy, -1=sell
enoughBars = na(lastSignalBar) or (bar_index - lastSignalBar >= minBars)
canBuy = longCond and enoughBars and (lastSignalType != 1)
canSell = shortCond and enoughBars and (lastSignalType != -1)
buySignal = canBuy
sellSignal = canSell
if buySignal
lastSignalBar := bar_index
lastSignalType := 1
if sellSignal
lastSignalBar := bar_index
lastSignalType := -1
plotshape(buySignal, title="BUY", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="SELL", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。