本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("MTF Momentum & Convexity Oscillator [AlgoChief] ", shorttitle="MDCO [AlgoChief]", overlay=false, max_lines_count=500, max_labels_count=500)
// ==========================================
// USER INPUTS & PARAMETERS
// ==========================================
grp_mtf = "Multi-Frequency Momentum Harmonics"
p_micro = input.int(8, "Micro Vector Period", minval=3, group=grp_mtf)
p_tactical = input.int(21, "Tactical Vector Period", minval=5, group=grp_mtf)
p_strat = input.int(55, "Strategic Vector Period", minval=10, group=grp_mtf)
p_macro = input.int(144, "Macro Vector Period", minval=20, group=grp_mtf)
grp_conv = "Convexity Engine (Second Derivative)"
smoothSig = input.int(9, "Signal Line Smoothing Length", minval=2, group=grp_conv)
grp_div = "Automated Divergence Engine"
showDiv = input.bool(true, "Show Subtle Divergence Markers", group=grp_div)
divLookback= input.int(5, "Pivot Confirmation Lookback", minval=2, maxval=20, group=grp_div)
grp_col = "Visual Styling"
c_wave_up = input.color(#00e5ff, "Momentum Bullish Wave", group=grp_col)
c_wave_dn = input.color(#ff5252, "Momentum Bearish Wave", group=grp_col)
c_sig = input.color(#ffb300, "Signal Guide Line", group=grp_col)
c_cohere = input.color(#ffd700, "Harmonic Coherence Squeeze Glow", group=grp_col)
// ==========================================
// HARMONIC MOMENTUM KINEMATICS
// ==========================================
normMom(len) =>
mom = close - close[len]
atr = ta.atr(len)
math.max(math.min((mom / math.max(atr, 0.000001)) * 25.0, 100.0), -100.0)
mMicro = normMom(p_micro)
mTactical = normMom(p_tactical)
mStrat = normMom(p_strat)
mMacro = normMom(p_macro)
// Composite Momentum Harmonic
compositeWave = (mMicro * 0.4) + (mTactical * 0.3) + (mStrat * 0.2) + (mMacro * 0.1)
signalLine = ta.ema(compositeWave, smoothSig)
// Convexity (Second Derivative / Acceleration)
velocity = compositeWave - compositeWave[1]
convexity = velocity - velocity[1]
bool accelUp = convexity > 0
// Momentum Dispersion Variance
meanVec = (mMicro + mTactical + mStrat + mMacro) / 4.0
varianceVec = (math.pow(mMicro - meanVec, 2) + math.pow(mTactical - meanVec, 2) +
math.pow(mStrat - meanVec, 2) + math.pow(mMacro - meanVec, 2)) / 4.0
dispersion = math.sqrt(varianceVec)
// Coherence Squeeze
bool isCoherent = dispersion < 15.0 and math.abs(compositeWave) > 20.0
// ==========================================
// ULTRA-CLEAN VISUAL OSCILLATOR
// ==========================================
// Reference Boundaries (Clean Dashed Levels)
hTop = hline(50, "Overbought Zone", color=color.new(#ff1744, 75), linestyle=hline.style_dashed)
hZero = hline(0, "Equilibrium", color=color.new(color.gray, 60), linestyle=hline.style_dotted)
hBtm = hline(-50, "Oversold Zone", color=color.new(#00e676, 75), linestyle=hline.style_dashed)
// Dynamic Color Gradient for the Main Curve
waveColor = isCoherent ? c_cohere : (compositeWave >= signalLine ? c_wave_up : c_wave_dn)
// Main Wave & Signal Plot
plot(compositeWave, title="Momentum Wave", color=waveColor, linewidth=2)
plot(signalLine, title="Kinetic Signal Line", color=color.new(c_sig, 30), linewidth=1)
// Clean Equilibrium Subtle Glow Fill
fill(hZero, hTop, color=color.new(#00e5ff, 96), title="Positive Wave Fill")
fill(hZero, hBtm, color=color.new(#ff5252, 96), title="Negative Wave Fill")
// Coherence Alignment Inception Marker (Clean, Non-Intrusive)
plotshape(isCoherent and not isCoherent[1], title="Coherence Alignment", style=shape.diamond,
location=location.top, color=c_cohere, size=size.tiny)
// ==========================================
// CLEAN SUBTLE DIVERGENCE ENGINE (NO CLUTTER)
// ==========================================
pLow = ta.pivotlow(compositeWave, divLookback, divLookback)
pHigh = ta.pivothigh(compositeWave, divLookback, divLookback)
var float lastOscPLow = na
var float lastOscPHigh = na
var float lastPricePLow = na
var float lastPricePHigh = na
if not na(pLow)
lastOscPLow := pLow
lastPricePLow := low[divLookback]
if not na(pHigh)
lastOscPHigh := pHigh
lastPricePHigh := high[divLookback]
// Divergence Logic
bullDiv = showDiv and not na(pLow) and not na(lastOscPLow[1]) and
(low[divLookback] < lastPricePLow[1]) and (pLow > lastOscPLow[1])
bearDiv = showDiv and not na(pHigh) and not na(lastOscPHigh[1]) and
(high[divLookback] > lastPricePHigh[1]) and (pHigh < lastOscPHigh[1])
// Clean Minimal Circles (No Giant Text Blocking Lines)
plotshape(bullDiv, title="Bullish Divergence", style=shape.circle,
location=location.bottom, color=#00e676, size=size.tiny, offset=-divLookback)
plotshape(bearDiv, title="Bearish Divergence", style=shape.circle,
location=location.top, color=#ff1744, size=size.tiny, offset=-divLookback)
// Alerts
alertcondition(ta.crossover(compositeWave, signalLine), title="[AlgoChief] Bullish Wave Crossover", message="[AlgoChief] Momentum Wave crossed ABOVE signal line at {{close}}")
alertcondition(ta.crossunder(compositeWave, signalLine), title="[AlgoChief] Bearish Wave Crossunder", message="[AlgoChief] Momentum Wave crossed BELOW signal line at {{close}}")
alertcondition(bullDiv, title="[AlgoChief] Bullish Divergence Alert", message="[AlgoChief] Regular Bullish Divergence Confirmed at {{close}}")
alertcondition(bearDiv, title="[AlgoChief] Bearish Divergence Alert", message="[AlgoChief] Regular Bearish Divergence Confirmed at {{close}}")
alertcondition(isCoherent and not isCoherent[1], title="[AlgoChief] Harmonic Coherence Squeeze", message="[AlgoChief] All 4 Momentum Timeframes Harmonized for Breakout at {{close}}")