Dino MDSO - Momentum Delta-Volume Sync. Oscillator

DinoTrading · study · 90 行 · 点赞 19 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org
// © DinoTrading
 
//@version=6
indicator("Dino MDSO - Momentum Delta-Volume Sync. Oscillator", shorttitle="MDSO", overlay=false, precision=2)
//MDSO = Momentum Delta-Volume Sync. Oscillator
 
// === INPUTS ===
lookback_bars   = input.int(20, "Lookback Histogramm", minval=2)
alma_window     = input.int(10, "ALMA smoothing", minval=1)
status_window   = input.int(80, "Line memory", minval=10)
show_status_line   = input.bool(true, "Show Cumulative Pressure Line?")
color_bars      = input.bool(true, "Candle color autom.")
 
// === COLORS ===
color_strong_up   = input.color(color.new(#2ac0c4, 0), "strong up")
color_weak_up     = input.color(color.new(#2ac0c4, 50), "weak up")
color_strong_down = input.color(color.new(#fcbe60, 25), "strong down")
color_weak_down   = input.color(color.new(#fcbe60, 50), "weak down")
color_status_line    = input.color(color.new(#cc5e1c, 20), "cumulative pressure line")
 
// === EFFICIENT INTRA-DAY DELTA FOR DAILY USE ===
float delta_calc = volume * (close - open) / (high - low + 0.00001)
float current_bar_delta = delta_calc
 
// === Continuous intraday delta without a session cutoff ===
var float accum_delta = 0.0
accum_delta += current_bar_delta
 
var float[] delta_history = array.new_float()
array.push(delta_history, current_bar_delta)
if array.size(delta_history) > lookback_bars
    array.shift(delta_history)
float cum_delta_roll = array.sum(delta_history)
 
// === MOMENTUM & Smoothing ===
float momentum_roll = close - close[lookback_bars]
float s_mom   = ta.alma(momentum_roll, alma_window, 0.85, 6)
float s_delta = ta.alma(cum_delta_roll, alma_window, 0.85, 6)
float s_day   = ta.alma(accum_delta, 20, 0.85, 6)
 
// === NORMALIZATION & WEIGHTING ===
len_norm = lookback_bars
norm_mom = (s_mom - ta.lowest(s_mom, len_norm)) / (math.max(ta.highest(s_mom, len_norm) - ta.lowest(s_mom, len_norm), 0.00001)) * 200 - 100
norm_delta = (s_delta - ta.lowest(s_delta, len_norm)) / (math.max(ta.highest(s_delta, len_norm) - ta.lowest(s_delta, len_norm), 0.00001)) * 200 - 100
 
float w_delta = math.min(0.9, 0.7 + (math.abs(norm_delta) / 300))
float osc_value = norm_delta * w_delta + norm_mom * (1 - w_delta)
 
// === UNHEDGED DYNAMICS FOR CANDLE COLOR ===
float osc_raw = s_delta * w_delta + s_mom * (1 - w_delta)
 
// === EFFICIENCY & ABSORPTION ===
float efficiency = math.abs(close - open) / (high - low + 0.00001)
float eff_smooth = ta.alma(efficiency, 5, 0.85, 6)
float sma_range = ta.sma(high - low, 20) 
bool absorption = math.abs(norm_delta) > 70 and eff_smooth < 0.3 and (high - low) > sma_range
 
// === STATUS LINE ===
float max_status = ta.highest(s_day, status_window)
float min_status = ta.lowest(s_day, status_window)
float day_status_line = ((s_day - min_status) / (math.max(max_status - min_status, 0.00001)) * 200) - 100
 
// === PLOTS & VISUALS ===
float prev_mid = (high[1] + low[1]) / 2
bool trigger_long  = low <= low[1] and close > prev_mid
bool trigger_short = high >= high[1] and close < prev_mid
 
plot(osc_value, "Histogramm", color=(osc_value > 0 ? (trigger_long ? color_strong_up : color_weak_up) : (trigger_short ? color_strong_down : color_weak_down)), style=plot.style_columns, linewidth=4)
plot(show_status_line ? day_status_line : na, "status line", color=color_status_line, linewidth=2)
 
hline(0, "mid", color=color.gray)
hline(100, "high limit", color=color.gray)
hline(-100, "low limit", color=color.gray)
bgcolor(absorption ? color.new(color.orange, 75) : na)
 
// === UNCOVERED CANDLE DYEING ===
float speed_current  = osc_raw - osc_raw[1]
float speed_previous = osc_raw[1] - osc_raw[2]
 
bool is_accelerating_up   = speed_current > 0 and speed_current >= speed_previous
bool is_accelerating_down = speed_current < 0 and speed_current <= speed_previous
 
color dynamic_bar_color = na
if osc_raw > 0
    dynamic_bar_color := is_accelerating_up ? color_strong_up : color_strong_down
else
    dynamic_bar_color := is_accelerating_down ? color_strong_down : color_strong_up
 
barcolor(color_bars ? dynamic_bar_color : na, title="math. candle color")

← 返回列表