根据移动均线指标复制,设定对应的均线将周期,1日均线和,7日均线然后尽心plot渲染,完成结果显示
//@version=4
study(title="Moving Average", shorttitle="MA", overlay=true, resolution="")
daylen = input(1, minval=1, title="Length")
daysrc = input(close, title="Source")
offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
dayout = sma(daysrc, daylen)
day7len = input(7, minval=1, title="Length")
day7src = input(close, title="Source")
off7set = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
day7out = sma(day7src, day7len)
plot(dayout, color=color.green, title="MA", offset=offset)
plot(day7out, color=color.blue, title="MA7", offset=offset)
如上的代码可以大致模拟双均线显示不过有两个问题:
1、 周期只能将在天级别以上无法设置到分钟
2、plot上面设置不了先出价格