PROTECTED SOURCE SCRIPT
업데이트됨 Trend Indicator (Advanced Multi-Filter Swing)

//version=6
indicator("Trend Indicator (Advanced Multi-Filter Swing)", overlay=true)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — MA ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ma_type = input.string('EMA', 'MA Type',
['ALMA','HMA','SMA','SWMA','VWMA','WMA','ZLEMA','EMA'], group='Setup')
ma_period = input.int(9, 'MA Period', minval=1, group='Setup')
alma_offset = input.float(0.85, 'ALMA Shift', 0, 1, 0.05, group='ALMA')
alma_sigma = input.int(6, 'ALMA Deviation', minval=1, group='ALMA')
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — SIGNAL LOGIC
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
momentumThreshold = input.int(25, "Momentum Threshold (Confirm)", group="Signal Logic")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — NOISE FILTERS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useSlopeFilter = input.bool(true, "Stronger Slope Filter", group="Noise Filters")
useVolatility = input.bool(true, "ATR Volatility Filter", group="Noise Filters")
useRangeFilter = input.bool(true, "Dead-Zone Filter", group="Noise Filters")
useBarFilter = input.bool(true, "Bar Structure Filter", group="Noise Filters")
useHTFProxy = input.bool(true, "HTF Proxy Slope Filter", group="Noise Filters")
deadZone = input.int(8, "Dead-Zone Value", group="Noise Filters")
atrLen = input.int(14, "ATR Length", group="Noise Filters")
atrMaLen = input.int(20, "ATR MA Length", group="Noise Filters")
htfProxyLen = input.int(6, "HTF Proxy Slope EMA Length", group="Noise Filters")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — ADX / DI FILTERS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useADX = input.bool(true, "Use ADX Filter", group="ADX / DI Filter")
useDI = input.bool(true, "Use DI+/DI− Filter", group="ADX / DI Filter")
adxLen = input.int(14, "ADX Length", group="ADX / DI Filter")
adxMin = input.int(20, "Minimum ADX", group="ADX / DI Filter")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — RSI FILTER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useRSI = input.bool(true, "Use RSI Filter", group="RSI Filter")
rsiLen = input.int(14, "RSI Length", group="RSI Filter")
rsiMid = input.int(50, "RSI Midline", group="RSI Filter")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// FUNCTIONS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
f_ma(x) =>
switch ma_type
'ALMA' => ta.alma(x, ma_period, alma_offset, alma_sigma)
'HMA' => ta.hma(x, ma_period)
'SMA' => ta.sma(x, ma_period)
'SWMA' => ta.swma(x)
'VWMA' => ta.vwma(x, ma_period)
'WMA' => ta.wma(x, ma_period)
'ZLEMA' => ta.ema(x + x - x[math.floor((ma_period - 1) / 2)], ma_period)
=> ta.ema(x, ma_period)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// HEIKIN-ASHI MA ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ha_open = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open))
ha_close = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close))
ha_high = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high))
ha_low = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low))
trend = 100 * (ha_close - ha_open) / (ha_high - ha_low)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// COLORS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bull = input.color(#26A69A, "Bullish", group="Colors")
bear = input.color(#EF5350, "Bearish", group="Colors")
neutral = input.color(#808080, "Neutral", group="Colors")
trendColor = trend > 0 ? bull : bear
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// VISUALS — TREND INDICATOR A
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
pOpen = plot(ha_open, display=display.none)
pClose = plot(ha_close, color=trendColor, linewidth=2)
pHigh = plot(ha_high, display=display.none)
pLow = plot(ha_low, display=display.none)
pHighBody = plot(math.max(ha_open, ha_close), display=display.none)
pLowBody = plot(math.min(ha_open, ha_close), display=display.none)
fill(pOpen, pClose, color.new(trendColor, 50))
fill(pHigh, pHighBody, color.new(neutral, 87))
fill(pLowBody, pLow, color.new(neutral, 87))
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// FILTER CALCULATIONS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
trendSlope = trend - trend[1]
slopeStrong = math.abs(trendSlope) > math.abs(trendSlope[1])
bullSlopeOK = trendSlope > 0
bearSlopeOK = trendSlope < 0
atr = ta.atr(atrLen)
atrMA = ta.sma(atr, atrMaLen)
volatilityOK = atr > atrMA
rangeOK = math.abs(trend) > deadZone
bullBar = close > open
bearBar = close < open
proxySlope = ta.ema(trendSlope, htfProxyLen)
proxyBullOK = proxySlope > 0
proxyBearOK = proxySlope < 0
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ADX / DI FILTERS (Pine v6 FINAL FIX)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[diPlus, diMinus, adxVal] = ta.dmi(adxLen, adxLen)
adxOK = adxVal > adxMin
diBullOK = diPlus > diMinus
diBearOK = diMinus > diPlus
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// RSI FILTER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
rsiVal = ta.rsi(close, rsiLen)
rsiBullOK = rsiVal > rsiMid
rsiBearOK = rsiVal < rsiMid
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// TWO-STAGE · ONE-SIGNAL-PER-SWING LOGIC
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
baseBull = ta.crossover(trend, 0)
baseBear = ta.crossunder(trend, 0)
earlyBull =
baseBull
and (not useSlopeFilter or (bullSlopeOK and slopeStrong))
and (not useVolatility or volatilityOK)
and (not useRangeFilter or rangeOK)
and (not useBarFilter or bullBar)
and (not useHTFProxy or proxyBullOK)
and (not useADX or adxOK)
and (not useRSI or rsiBullOK)
and (not useDI or diBullOK)
earlyBear =
baseBear
and (not useSlopeFilter or (bearSlopeOK and slopeStrong))
and (not useVolatility or volatilityOK)
and (not useRangeFilter or rangeOK)
and (not useBarFilter or bearBar)
and (not useHTFProxy or proxyBearOK)
and (not useADX or adxOK)
and (not useRSI or rsiBearOK)
and (not useDI or diBearOK)
confirmBull = trend > 0 and math.abs(trend) > momentumThreshold
confirmBear = trend < 0 and math.abs(trend) > momentumThreshold
var int swingDir = 0
var bool confirmed = false
earlyBUY = earlyBull and swingDir != 1
earlySELL = earlyBear and swingDir != -1
if earlyBUY
swingDir := 1
confirmed := false
else if earlySELL
swingDir := -1
confirmed := false
confirmedBUY = swingDir == 1 and not confirmed and confirmBull
confirmedSELL = swingDir == -1 and not confirmed and confirmBear
if confirmedBUY or confirmedSELL
confirmed := true
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SIGNAL PLOTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plotshape(earlyBUY, "BUY Early", shape.triangleup,
location=location.belowbar, size=size.tiny, color=bull, text="BUY")
plotshape(earlySELL, "SELL Early", shape.triangledown,
location=location.abovebar, size=size.tiny, color=bear, text="SELL")
plotshape(confirmedBUY, "BUY Confirmed", shape.labelup,
location=location.belowbar, color=bull, text="BUY✔")
plotshape(confirmedSELL, "SELL Confirmed", shape.labeldown,
location=location.abovebar, color=bear, text="SELL✔")
indicator("Trend Indicator (Advanced Multi-Filter Swing)", overlay=true)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — MA ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ma_type = input.string('EMA', 'MA Type',
['ALMA','HMA','SMA','SWMA','VWMA','WMA','ZLEMA','EMA'], group='Setup')
ma_period = input.int(9, 'MA Period', minval=1, group='Setup')
alma_offset = input.float(0.85, 'ALMA Shift', 0, 1, 0.05, group='ALMA')
alma_sigma = input.int(6, 'ALMA Deviation', minval=1, group='ALMA')
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — SIGNAL LOGIC
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
momentumThreshold = input.int(25, "Momentum Threshold (Confirm)", group="Signal Logic")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — NOISE FILTERS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useSlopeFilter = input.bool(true, "Stronger Slope Filter", group="Noise Filters")
useVolatility = input.bool(true, "ATR Volatility Filter", group="Noise Filters")
useRangeFilter = input.bool(true, "Dead-Zone Filter", group="Noise Filters")
useBarFilter = input.bool(true, "Bar Structure Filter", group="Noise Filters")
useHTFProxy = input.bool(true, "HTF Proxy Slope Filter", group="Noise Filters")
deadZone = input.int(8, "Dead-Zone Value", group="Noise Filters")
atrLen = input.int(14, "ATR Length", group="Noise Filters")
atrMaLen = input.int(20, "ATR MA Length", group="Noise Filters")
htfProxyLen = input.int(6, "HTF Proxy Slope EMA Length", group="Noise Filters")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — ADX / DI FILTERS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useADX = input.bool(true, "Use ADX Filter", group="ADX / DI Filter")
useDI = input.bool(true, "Use DI+/DI− Filter", group="ADX / DI Filter")
adxLen = input.int(14, "ADX Length", group="ADX / DI Filter")
adxMin = input.int(20, "Minimum ADX", group="ADX / DI Filter")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS — RSI FILTER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useRSI = input.bool(true, "Use RSI Filter", group="RSI Filter")
rsiLen = input.int(14, "RSI Length", group="RSI Filter")
rsiMid = input.int(50, "RSI Midline", group="RSI Filter")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// FUNCTIONS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
f_ma(x) =>
switch ma_type
'ALMA' => ta.alma(x, ma_period, alma_offset, alma_sigma)
'HMA' => ta.hma(x, ma_period)
'SMA' => ta.sma(x, ma_period)
'SWMA' => ta.swma(x)
'VWMA' => ta.vwma(x, ma_period)
'WMA' => ta.wma(x, ma_period)
'ZLEMA' => ta.ema(x + x - x[math.floor((ma_period - 1) / 2)], ma_period)
=> ta.ema(x, ma_period)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// HEIKIN-ASHI MA ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ha_open = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open))
ha_close = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close))
ha_high = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high))
ha_low = f_ma(request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low))
trend = 100 * (ha_close - ha_open) / (ha_high - ha_low)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// COLORS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bull = input.color(#26A69A, "Bullish", group="Colors")
bear = input.color(#EF5350, "Bearish", group="Colors")
neutral = input.color(#808080, "Neutral", group="Colors")
trendColor = trend > 0 ? bull : bear
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// VISUALS — TREND INDICATOR A
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
pOpen = plot(ha_open, display=display.none)
pClose = plot(ha_close, color=trendColor, linewidth=2)
pHigh = plot(ha_high, display=display.none)
pLow = plot(ha_low, display=display.none)
pHighBody = plot(math.max(ha_open, ha_close), display=display.none)
pLowBody = plot(math.min(ha_open, ha_close), display=display.none)
fill(pOpen, pClose, color.new(trendColor, 50))
fill(pHigh, pHighBody, color.new(neutral, 87))
fill(pLowBody, pLow, color.new(neutral, 87))
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// FILTER CALCULATIONS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
trendSlope = trend - trend[1]
slopeStrong = math.abs(trendSlope) > math.abs(trendSlope[1])
bullSlopeOK = trendSlope > 0
bearSlopeOK = trendSlope < 0
atr = ta.atr(atrLen)
atrMA = ta.sma(atr, atrMaLen)
volatilityOK = atr > atrMA
rangeOK = math.abs(trend) > deadZone
bullBar = close > open
bearBar = close < open
proxySlope = ta.ema(trendSlope, htfProxyLen)
proxyBullOK = proxySlope > 0
proxyBearOK = proxySlope < 0
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ADX / DI FILTERS (Pine v6 FINAL FIX)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[diPlus, diMinus, adxVal] = ta.dmi(adxLen, adxLen)
adxOK = adxVal > adxMin
diBullOK = diPlus > diMinus
diBearOK = diMinus > diPlus
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// RSI FILTER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
rsiVal = ta.rsi(close, rsiLen)
rsiBullOK = rsiVal > rsiMid
rsiBearOK = rsiVal < rsiMid
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// TWO-STAGE · ONE-SIGNAL-PER-SWING LOGIC
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
baseBull = ta.crossover(trend, 0)
baseBear = ta.crossunder(trend, 0)
earlyBull =
baseBull
and (not useSlopeFilter or (bullSlopeOK and slopeStrong))
and (not useVolatility or volatilityOK)
and (not useRangeFilter or rangeOK)
and (not useBarFilter or bullBar)
and (not useHTFProxy or proxyBullOK)
and (not useADX or adxOK)
and (not useRSI or rsiBullOK)
and (not useDI or diBullOK)
earlyBear =
baseBear
and (not useSlopeFilter or (bearSlopeOK and slopeStrong))
and (not useVolatility or volatilityOK)
and (not useRangeFilter or rangeOK)
and (not useBarFilter or bearBar)
and (not useHTFProxy or proxyBearOK)
and (not useADX or adxOK)
and (not useRSI or rsiBearOK)
and (not useDI or diBearOK)
confirmBull = trend > 0 and math.abs(trend) > momentumThreshold
confirmBear = trend < 0 and math.abs(trend) > momentumThreshold
var int swingDir = 0
var bool confirmed = false
earlyBUY = earlyBull and swingDir != 1
earlySELL = earlyBear and swingDir != -1
if earlyBUY
swingDir := 1
confirmed := false
else if earlySELL
swingDir := -1
confirmed := false
confirmedBUY = swingDir == 1 and not confirmed and confirmBull
confirmedSELL = swingDir == -1 and not confirmed and confirmBear
if confirmedBUY or confirmedSELL
confirmed := true
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SIGNAL PLOTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plotshape(earlyBUY, "BUY Early", shape.triangleup,
location=location.belowbar, size=size.tiny, color=bull, text="BUY")
plotshape(earlySELL, "SELL Early", shape.triangledown,
location=location.abovebar, size=size.tiny, color=bear, text="SELL")
plotshape(confirmedBUY, "BUY Confirmed", shape.labelup,
location=location.belowbar, color=bull, text="BUY✔")
plotshape(confirmedSELL, "SELL Confirmed", shape.labeldown,
location=location.abovebar, color=bear, text="SELL✔")
릴리즈 노트
This Pine Script (v6) is a sophisticated Trend-Following indicator that uses Heikin-Ashi candles processed through various moving averages to filter out "market noise." Instead of just looking at price, it looks at the momentum and quality of the trend. Here is the breakdown of the logic and how the interface works. 1. The Core Logic: The "HA Engine" The heart of the script isn't just a standard Moving Average (MA). It calculates a synthetic trend based on Heikin-Ashi (HA) data. Heikin-Ashi Smoothing: It takes the Open, High, Low, and Close of HA candles and applies your chosen Moving Average (e.g., EMA, ALMA, or ZLEMA) to them. The Trend Formula: It calculates a "Trend Score": $$100 \times \frac{HA_{Close} - HA_{Open}} {HA_{High} - HA_{Low}} $$What this does: This creates a value between -100 and +100. If the body of the smoothed HA candle is large relative to its wicks, the trend is considered strong. 2. The Multi-Filter "Gauntlet" The script is designed to be "picky." It won't show a signal unless several conditions are met simultaneously (if you have them enabled): Slope Filter: Ensures the trend is actually accelerating (getting steeper). Volatility (ATR) Filter: Only signals when the current ATR is higher than its average (ensuring there is enough "juice" in the move). Dead-Zone Filter: Ignores small, choppy movements near the zero line. HTF Proxy: Uses an EMA of the slope to act as a "higher time frame" confirmation to ensure you aren't trading against the primary momentum. ADX/DI Filter: Uses the Average Directional Index to ensure a trend exists (보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.