好库网 好库网首页 | 我的好库
blockchain的专栏

文章分类

TradingView添加20,60,120 Sma均线指标公式源码

发布者:blockchain
发布日期:2021/7/17 21:15:00   更新日期:2021/7/17 21:22:00
阅读次数:63
评分:4.80
介绍:均线系统代码,原来的代码在最新的tradingview中有问题,小编作了修改。
正文:

strategy("我的策略", overlay = true, calc_on_every_tick=true)

 

// Add SMA 20, 60 and 120

study(title="Sma 20, 60 and 120", shorttitle="Sma", overlay=true)

 

//sma 20

sma20Source = input(defval = close)

sma20Length = input(defval = 20, minval = 1)

 

//longest sma 60

sma60Source = input(defval = close)

sma60Length = input(defval = 60, minval = 1)

 

// far longest sma 120

sma120Source = input(defval = close)

sma120Length = input(defval = 120, minval = 1)

 

//定义sma

sma20 = sma(sma20Source, sma20Length)

sma60 = sma(sma60Source, sma60Length)

sma120 = sma(sma120Source, sma120Length)

 

//画线

plot(series=sma20, title="sma20", color = color.red, linewidth=1)

plot(series=sma60, title="sma60", color = color.green, linewidth=1)

plot(series=sma120, title="sma120", color = color.blue, linewidth=1)

 

//画指示圆点

//Early Cross, sma20 cross to sma 60

plot(cross(sma20, sma60) ? sma60 : na, style=plot.style_circles, linewidth = 4, color=#f92cd7, title="Early Cross")

//Golden Cross, sma 55 cross to sma120

plot(cross(sma20, sma120) ? sma120 : na, style=plot.style_circles, linewidth = 4, color=#ff5be9, title="Golden Cross")


评论 [发表评论]
账号 密码 还没帐号呢,现在注册一个?

免责声明:好库网所展示的信息由买卖双方自行提供,其真实性、准确性和合法性由信息发布人负责。好库网不提供任何保证,并不承担任何法律责任。