权威网站: 美股之家

Trading view 多指标源码,最强均线、布林线、顾比均线、哈希纽带、抛物线转向

//@version=4
study(title="最强均线", overlay=true)

// 均线系统
at_show_ma_system = input(true, title="是否显示 - 均线系统")
at_ma_type = input("SMA", title="移动平均线种类", options=["SMA", "WMA", "HMA", "EMA"])
at_ma_number = input("全显示", title="均线数量", options=["全显示", "双均线"])
at_ma_len_1= input(8, minval=1, title="Length")
at_ma_len_2= input(21, minval=1, title="双均线-短")
at_ma_len_3= input(34, minval=1, title="Length")
at_ma_len_4= input(55, minval=1, title="双均线-长")
at_ma_len_5= input(89, minval=1, title="Length")
at_ma_len_6= input(144, minval=1, title="Length")
at_ma_len_7= input(233, minval=1, title="Length")

at_ma_graph_1 = sma(close, at_ma_len_1)
at_ma_graph_2 = sma(close, at_ma_len_2)
at_ma_graph_3 = sma(close, at_ma_len_3)
at_ma_graph_4 = sma(close, at_ma_len_4)
at_ma_graph_5 = sma(close, at_ma_len_5)
at_ma_graph_6 = sma(close, at_ma_len_6)
at_ma_graph_7 = sma(close, at_ma_len_7)

if at_ma_type == "WMA"
at_ma_graph_1 := wma(close, at_ma_len_1)
at_ma_graph_2 := wma(close, at_ma_len_2)
at_ma_graph_3 := wma(close, at_ma_len_3)
at_ma_graph_4 := wma(close, at_ma_len_4)
at_ma_graph_5 := wma(close, at_ma_len_5)
at_ma_graph_6 := wma(close, at_ma_len_6)
at_ma_graph_7 := wma(close, at_ma_len_7)
if at_ma_type == "EMA"
at_ma_graph_1 := ema(close, at_ma_len_1)
at_ma_graph_2 := ema(close, at_ma_len_2)
at_ma_graph_3 := ema(close, at_ma_len_3)
at_ma_graph_4 := ema(close, at_ma_len_4)
at_ma_graph_5 := ema(close, at_ma_len_5)
at_ma_graph_6 := ema(close, at_ma_len_6)
at_ma_graph_7 := ema(close, at_ma_len_7)
if at_ma_type == "HMA"
at_ma_graph_1 := hma(close, at_ma_len_1)
at_ma_graph_2 := hma(close, at_ma_len_2)
at_ma_graph_3 := hma(close, at_ma_len_3)
at_ma_graph_4 := hma(close, at_ma_len_4)
at_ma_graph_5 := hma(close, at_ma_len_5)
at_ma_graph_6 := hma(close, at_ma_len_6)
at_ma_graph_7 := hma(close, at_ma_len_7)


plot(at_ma_graph_1, title="Graph_1", color=color.red, transp= at_show_ma_system ? (at_ma_number=="双均线" ? 100 : 0) : 100)
plot(at_ma_graph_2, title="Graph_2", color=color.orange, transp= at_show_ma_system ? 0 : 100)
plot(at_ma_graph_3, title="Graph_3", color=color.yellow, transp= at_show_ma_system ? (at_ma_number=="双均线" ? 100 : 0) : 100)
plot(at_ma_graph_4, title="Graph_4", color=color.green, transp= at_show_ma_system ? 0 : 100)
plot(at_ma_graph_5, title="Graph_5", color=color.blue, transp= at_show_ma_system ? (at_ma_number=="双均线" ? 100 : 0) : 100)
plot(at_ma_graph_6, title="Graph_6", color=color.purple, transp= at_show_ma_system ? (at_ma_number=="双均线" ? 100 : 0) : 100)
plot(at_ma_graph_7, title="Graph_7", color=color.black, transp= at_show_ma_system ? (at_ma_number=="双均线" ? 100 : 0) : 100)

// 布林线
at_show_bollingerband = input(false, title="是否显示 - 布林线")
length = input(50, minval=1, title="布林线量參")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = sma(close, length)
dev = mult * stdev(close, length)
upper = basis + dev
lower = basis - dev
offset = input(0,"Offset", type = input.integer, minval = -500, maxval = 500)
plot(basis, "Basis", color=#872323, offset = offset, transp= at_show_bollingerband ? 0: 100)
p1 = plot(upper, "Upper", color=color.teal, offset = offset, transp= at_show_bollingerband ? 0: 100)
p2 = plot(lower, "Lower", color=color.teal, offset = offset, transp= at_show_bollingerband ? 0: 100)
fill(p1,p2,title = "background", color=#198787, transp=at_show_bollingerband ? 95: 100)


// 顾比均线
at_show_gmma = input(false, title="是否显示 - GMMA - 顾比均线")
at_gmma_ema1 = ema(close, 3)
at_gmma_ema2 = ema(close, 5)
at_gmma_ema3 = ema(close, 8)
at_gmma_ema4 = ema(close, 10)
at_gmma_ema5 = ema(close, 12)
at_gmma_ema6 = ema(close, 15)
at_gmma_ema7 = ema(close, 30)
at_gmma_ema8 = ema(close, 35)
at_gmma_ema9 = ema(close, 40)
at_gmma_ema10 = ema(close, 45)
at_gmma_ema11 = ema(close, 50)
at_gmma_ema12 = ema(close, 60)

plot(at_gmma_ema1, color=color.green, title="s1", transp= at_show_gmma ? 0: 100) // s: short
plot(at_gmma_ema2, color=color.green, title="s2", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema3, color=color.green, title="s3", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema4, color=color.green, title="s4", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema5, color=color.green, title="s5", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema6, color=color.green, title="s6", transp= at_show_gmma ? 0: 100)

plot(at_gmma_ema7, color=color.red, title="l1", transp= at_show_gmma ? 0: 100) // l: long
plot(at_gmma_ema8, color=color.red, title="l2", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema9, color=color.red, title="l3", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema10, color=color.red, title="l4", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema11, color=color.red, title="l5", transp= at_show_gmma ? 0: 100)
plot(at_gmma_ema12, color=color.red, title="l6", transp= at_show_gmma ? 0: 100)


//移动纽带
at_show_hashribbon = input(false, title="是否显示 - HashRibbon - 哈希纽带")
dropn(src, n) =>
na(src[n]) ? na : src
dropCandles = input(1, minval=0, title="Drop first N candles")

price = dropn(close, dropCandles)

plot(ema(price, 20), title="MA-1", color=#f5eb5d, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)
plot(ema(price, 25), title="MA-2", color=#f5b771, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)
plot(ema(price, 30), title="MA-3", color=#f5b056, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)
plot(ema(price, 35), title="MA-4", color=#f57b4e, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)
plot(ema(price, 40), title="MA-5", color=#f56d58, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)
plot(ema(price, 45), title="MA-6", color=#f57d51, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)
plot(ema(price, 50), title="MA-7", color=#f55151, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)
plot(ema(price, 55), title="MA-8", color=#aa2707, offset=0, linewidth=2, transp= at_show_hashribbon ? 0: 100)

//抛物线转向
at_show_sar = input(false, title="是否显示 - SAR - 抛物线转向")
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
out = sar(start, increment, maximum)
plot(out, "ParabolicSAR", style=plot.style_cross, color=#2962FF, transp= at_show_sar ? 0: 100)

文章极致简洁
数字化区块时代 » 股市秘籍

发表回复