本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=5
indicator("Professional RF: Balanced Edition", overlay=true)
// ==========================================
// 1. INPUT PARAMETRI
// ==========================================
emaLength = input.int(200, title="Filtro Trend (EMA 200)")
rfPer = input.int(100, title="Range Period")
rfMult = input.float(3.0, title="Range Multiplier")
// Filtro Volume (Più leggero dell'ADX)
useVolFilter = input.bool(true, title="Usa Filtro Volume (Anti-Flat)")
volLength = input.int(20, title="Media Volume")
// ==========================================
// 2. CALCOLI TECNICI
// ==========================================
// EMA 200
ema200 = ta.ema(close, emaLength)
// Range Filter Logic
var float filter = na
smrng = ta.ema(ta.atr(1), rfPer) * rfMult
filter := close > nz(filter[1]) ? math.max(nz(filter[1]), close - smrng) : math.min(nz(filter[1]), close + smrng)
// Calcolo Volume
volAvg = ta.sma(volume, volLength)
volConfirm = useVolFilter ? volume >= volAvg : true
// Direzione
bool isUpward = close > filter
bool isDownward = close < filter
// ==========================================
// 3. LOGICA SEGNALI PULITI (ANTI-RUMORE)
// ==========================================
var int lastSignal = 0
// Condizione Buy: Filtro gira, sopra EMA 200, conferma Volume
buyCond = isUpward and not (close[1] > filter[1]) and close > ema200 and volConfirm and lastSignal <= 0
if buyCond
lastSignal := 1
// Condizione Sell: Filtro gira, sotto EMA 200, conferma Volume
sellCond = isDownward and not (close[1] < filter[1]) and close < ema200 and volConfirm and lastSignal >= 0
if sellCond
lastSignal := -1
// ==========================================
// 4. VISUALIZZAZIONE
// ==========================================
plot(filter, color=isUpward ? color.green : color.red, linewidth=3, title="Range Filter")
plot(ema200, color=color.new(color.yellow, 50), title="EMA 200")
plotshape(buyCond, title="BUY", style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, text="BUY", textcolor=color.white)
plotshape(sellCond, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small, text="SELL", textcolor=color.white)
// Alert
alertcondition(buyCond, "BUY", "Segnale BUY con Volumi!")
alertcondition(sellCond, "SELL", "Segnale SELL con Volumi!")