本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=4
strategy("EVWMA VWAP MACD Strategy [QuantNomad]", shorttitle="EVWMA_VWAP_MACD[QN]", overlay=false)
// Inputs
sum_length = input(30, title = "EVWMA Length", type = input.integer)
signal_length1 = input(5, title = "Signal Smoothing 1", type = input.integer)
signal_length2 = input(20, title = "Signal Smoothing 2", type = input.integer)
// Calculate EVWMA
vol_period = sum(volume, sum_length)
evwma = 0.0
evwma := ((vol_period - volume) * nz(evwma[1], close) + volume * close) / (vol_period)
// Calculate MACD
diff = vwap - evwma
macd = ema(diff, signal_length1)
signal = ema(diff, signal_length2)
hist = macd - signal
// Plot
plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) ), transp=0 )
plot(macd, title="MACD", color= #0094ff, transp=0)
plot(signal, title="Signal", color= #ff6a00, transp=0)
// Strategy
strategy.entry("short", false, when = crossunder(macd, signal))
strategy.entry("long", true, when = crossover(macd, signal) )