Vegas 隧道 Tradingview Pine 指标
//@version=5
indicator('维加斯隧道', overlay=true)
//过滤线
MA0Visible = input(title='计算过滤线', defval=true)
MA0Period = input.int(title='过滤线', defval=12, minval=1)
MA0Type = input.string(title='均线类型', defval='EMA', options=['SMA', 'EMA', 'WMA', 'RMA'])
MA0Source = input(title='均线来源', defval=close)
//MA1
MA1Visible = input(title='计算均线1', defval=true)
MA1Period = input.int(title='均线1', defval=144, minval=1)
MA1Type = input.string(title='均线类型', defval='EMA', options=['SMA', 'EMA', 'WMA', 'RMA'])
MA1Source = input(title='均线来源', defval=close)
//MA2
MA2Visible = input(title='计算均线2', defval=true)
MA2Period = input.int(title='均线2', defval=169, minval=1)
MA2Type = input.string(title='均线类型', defval='EMA', options=['SMA', 'EMA', 'WMA', 'RMA'])
MA2Source = input(title='均线来源', defval=close)
//MA3
MA3Visible = input(title='计算均线3', defval=true)
MA3Period = input.int(title='均线3', defval=288, minval=1)
MA3Type = input.string(title='均线类型', defval='EMA', options=['SMA', 'EMA', 'WMA', 'RMA'])
MA3Source = input(title='均线来源', defval=close)
//MA4
MA4Visible = input(title='计算均线4', defval=true)
MA4Period = input.int(title='均线4', defval=338, minval=1)
MA4Type = input.string(title='均线类型', defval='EMA', options=['SMA', 'EMA', 'WMA', 'RMA'])
MA4Source = input(title='均线来源', defval=close)
// 添加开关来控制是否在隧道之间填充颜色
show_fill = input(true, title="填充颜色")
MA0 = if MA0Type == 'SMA'
ta.sma(MA0Source, MA0Period)
else
if MA0Type == 'EMA'
ta.ema(MA0Source, MA0Period)
else
if MA0Type == 'WMA'
ta.wma(MA0Source, MA0Period)
else
if MA0Type == 'RMA'
ta.rma(MA0Source, MA0Period)
MA1 = if MA1Type == 'SMA'
ta.sma(MA1Source, MA1Period)
else
if MA1Type == 'EMA'
ta.ema(MA1Source, MA1Period)
else
if MA1Type == 'WMA'
ta.wma(MA1Source, MA1Period)
else
if MA1Type == 'RMA'
ta.rma(MA1Source, MA1Period)
MA2 = if MA2Type == 'SMA'
ta.sma(MA2Source, MA2Period)
else
if MA2Type == 'EMA'
ta.ema(MA2Source, MA2Period)
else
if MA2Type == 'WMA'
ta.wma(MA2Source, MA2Period)
else
if MA2Type == 'RMA'
ta.rma(MA2Source, MA2Period)
MA3 = if MA3Type == 'SMA'
ta.sma(MA3Source, MA3Period)
else
if MA3Type == 'EMA'
ta.ema(MA3Source, MA3Period)
else
if MA3Type == 'WMA'
ta.wma(MA3Source, MA3Period)
else
if MA3Type == 'RMA'
ta.rma(MA3Source, MA3Period)
MA4 = if MA4Type == 'SMA'
ta.sma(MA4Source, MA4Period)
else
if MA4Type == 'EMA'
ta.ema(MA4Source, MA4Period)
else
if MA4Type == 'WMA'
ta.wma(MA4Source, MA4Period)
else
if MA4Type == 'RMA'
ta.rma(MA4Source, MA4Period)
plot_MA0 = plot(MA0Visible ? MA0 : na, color=color.rgb(149, 152, 161), linewidth=1,title = "过滤线")
plot_MA1 = plot(MA1Visible ? MA1 : na, color=color.rgb(189, 191, 189, 90), linewidth=1, title = "均线1")
plot_MA2 = plot(MA2Visible ? MA2 : na, color=color.rgb(189, 191, 189, 90), linewidth=1, title = "均线2")
plot_MA3 = plot(MA3Visible ? MA3 : na, color=color.rgb(189, 191, 189, 90), linewidth=1, title = "均线3")
plot_MA4 = plot(MA4Visible ? MA4 : na, color=color.rgb(189, 191, 189, 90), linewidth=1, title = "均线4")
// 定义填充颜色,根据开关状态设置透明度
fill_color144 = show_fill ? color.rgb(149, 152, 161, 80) : na
fill_color288 = show_fill ? color.rgb(149, 152, 161, 80) : na
// 在EMA 144和EMA 169之间填充颜色
fill(plot_MA1, plot_MA2, color=fill_color144)
// 在EMA 288和EMA 338之间填充颜色
fill(plot_MA3, plot_MA4, color=fill_color288)
在Tradingview点击“Pine编辑器-打开-新指标”复制粘贴以上代码
License:
CC BY 4.0