OPEN-SOURCE SCRIPT

Coppock Normalized (Z-score) [v6]

18
//version=6
indicator("Coppock Normalized (Z-score) [v6]", overlay=false)

// ┌─ 입력값
rocLen1 = input.int(14, "ROC1 Length", minval=1)
rocLen2 = input.int(11, "ROC2 Length", minval=1)
wmaLen = input.int(10, "WMA Length", minval=1)
zLen = input.int(200, "Z-score Lookback", minval=5)
signalLen = input.int(5, "Signal SMA", minval=1)
tfCalc = input.timeframe("", "Calc Timeframe (optional, e.g., 1M)")

thPos = input.float( 1.5, "Upper Threshold (Z)")
thNeg = input.float(-1.5, "Lower Threshold (Z)")

// ┌─ 소스 시계열 (고타임프레임 옵션 지원)
src = tfCalc == "" ? close : request.security(syminfo.tickerid, tfCalc, close)

// ┌─ 코폭 커브 (전통식): WMA of (ROC(14) + ROC(11))
roc1 = ta.roc(src, rocLen1)
roc2 = ta.roc(src, rocLen2)
coppock_raw = ta.wma(roc1 + roc2, wmaLen)

// ┌─ Z-score 정규화: (x - mean) / stdev
meanC = ta.sma(coppock_raw, zLen)
stdevC = ta.stdev(coppock_raw, zLen)
z = (stdevC == 0.0 or na(stdevC)) ? na : (coppock_raw - meanC) / stdevC

// ┌─ 시그널(스무딩)
zSignal = ta.sma(z, signalLen)

// ┌─ 보조선
h0 = hline(0.0, "Zero", color=color.new(color.gray, 0))
hUp = hline(thPos, "Z Upper", color=color.new(color.teal, 0))
hDn = hline(thNeg, "Z Lower", color=color.new(color.purple, 0))
fill(h0, hDn, color=color.new(color.red, 85))
fill(h0, hUp, color=color.new(color.green, 88))

// ┌─ 플롯
plot(z, title="Coppock Z", color = z >= 0 ? color.new(color.green, 0) : color.new(color.red, 0), linewidth=2)
plot(zSignal, title="Signal", color = color.new(color.blue, 0), linewidth=1)

// ┌─ 보조 정보(기울기)
zSlope = ta.change(z)
plot(zSlope, title="Z Slope (ΔZ)", color=color.new(color.orange, 0), linewidth=1, display=display.none)

// ┌─ 알림 조건
alertcondition(ta.crossover(z, 0), "Z crosses above 0", "Coppock Z crossed above 0")
alertcondition(ta.crossunder(z, 0), "Z crosses below 0", "Coppock Z crossed below 0")
alertcondition(ta.crossover(z, thNeg), "Z crosses above Lower", "Coppock Z crossed above Lower threshold")
alertcondition(ta.crossunder(z, thPos), "Z crosses below Upper", "Coppock Z crossed below Upper threshold")
alertcondition(ta.crossover(z, zSignal), "Z crosses above Signal", "Coppock Z crossed above Signal")
alertcondition(ta.crossunder(z, zSignal), "Z crosses below Signal", "Coppock Z crossed below Signal")

// ┌─ 상태 라벨
var label lb = na
if barstate.islast and not na(z)
label.delete(lb)
lb := label.new(bar_index, z, style=label.style_label_left, textcolor=color.white, color=color.new(color.black, 20))

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.