代码来自B站up主的免费分享,有需要的可以拿去用。
此代码适用于tradingview系统。我自己加多一对200移动均线,不需要的可以勾选去掉。
//@version=4
study(“MA+EMA”,overlay=true)
e1=ema(close,20)
c1=sma(close,20)
e2=ema(close,60)
c2=sma(close,60)
e3=ema(close,120)
c3=sma(close,120)
e4=ema(close,200)
c4=sma(close,200)
plot(e1,”ema20”,color=color.gray)
plot(c1,”ma20”,color=#D3D3D3)
plot(e2,”ema60”,color=color.red)
plot(c2,”ma60”,color=#FDBCB4)
plot(e3,”ema120”,color=color.blue)
plot(c3,”ma120”,color=#ADD8E6)
plot(e4,”ema200”,color=color.black)
plot(c4,”ma200”,color=#787b86)
//DK3
cond=barstate.islast
moveBar = input(0)
x20=input(20)+moveBar
x60=input(60)+moveBar
x120=input(120)+moveBar
x200=input(200)+moveBar
plot(cond?low[20]:na,color=#FFC40C,linewidth=5,offset=-x20,style=plot.style_circles,transp=0)
plot(cond?low[60]:na,color=#FFC40C,linewidth=5,offset=-x60,style=plot.style_circles,transp=0)
plot(cond?low[120]:na,color=#FFC40C,linewidth=5,offset=-x120,style=plot.style_circles,transp=0)
plot(cond?low[200]:na,color=#FFC40C,linewidth=5,offset=-x200,style=plot.style_circles,transp=0)
//@version=4
study("MA+EMA",overlay=true)
e1=ema(close,20)
c1=sma(close,20)
e2=ema(close,60)
c2=sma(close,60)
e3=ema(close,120)
c3=sma(close,120)
e4=ema(close,200)
c4=sma(close,200)
plot(e1,"ema20",color=color.gray)
plot(c1,"ma20",color=#D3D3D3)
plot(e2,"ema60",color=color.red)
plot(c2,"ma60",color=#FDBCB4)
plot(e3,"ema120",color=color.blue)
plot(c3,"ma120",color=#ADD8E6)
plot(e4,"ema200",color=color.black)
plot(c4,"ma200",color=#787b86)
//DK3
cond=barstate.islast
moveBar = input(0)
x20=input(20)+moveBar
x60=input(60)+moveBar
x120=input(120)+moveBar
x200=input(200)+moveBar
plot(cond?low[20]:na,color=#FFC40C,linewidth=5,offset=-x20,style=plot.style_circles,transp=0)
plot(cond?low[60]:na,color=#FFC40C,linewidth=5,offset=-x60,style=plot.style_circles,transp=0)
plot(cond?low[120]:na,color=#FFC40C,linewidth=5,offset=-x120,style=plot.style_circles,transp=0)
plot(cond?low[200]:na,color=#FFC40C,linewidth=5,offset=-x200,style=plot.style_circles,transp=0)
B站up主链接[https://www.bilibili.com/video/BV1av411w7jj?spm_id_from=333.999.0.0&vd_source=6f9c52354e28d557e63915515a768f03]