MACD VWAP V2 [BETA]

mastixmc · study · 48 行 · 点赞 2,700 · TradingView 原页

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

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sascha Sambale
 
//@version=4
study(title="MACD VWAP", shorttitle="MACD VWAP", overlay=true, resolution="")
 
// Getting inputs
fast_length = input(title="Fast Length", type=input.integer, defval=12)
slow_length = input(title="Slow Length", type=input.integer, defval=26)
fast_ema = input(title="Fast EMA", type=input.integer, defval=9)
 
src = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
 
// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00
 
// Calculating
fast_ma = ema(src, fast_length)
slow_ma = ema(src, slow_length)
macd = fast_ma - slow_ma
signal = ema(macd, signal_length)
hist = macd - signal
vwapLine = vwap(close)
EMA9 = ema(close, fast_ema)
EMA200 = ema(close, 200)
 
vwap_crossup=signal < 0 and crossover(EMA9, vwapLine)
vwap_crossdown=macd < 0 and crossunder(EMA9, vwapLine)
 
bullish = close > vwapLine and close > EMA9 and vwap_crossup
bearish = close < vwapLine and close < EMA9 and vwap_crossdown
 
alertcondition(bullish, title='Bullish VWAP Crossover detected', message="Bullish trend detected")
alertcondition(bearish, title='Bearish VWAP Crossover detected', message='Bearish trend detected')
 
plot(vwapLine, color=color.orange, linewidth=2)
plot(EMA9, color=color.red, linewidth=2)
plot(EMA200, color=color.blue, linewidth=4)
 
 
plotshape(bullish, title="buy", text="Buy", color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0)  //plot for buy icon
plotshape(bearish, title="sell", text="Sell", color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0)  //plot for sell icon

← 返回列表