设为首页 收藏本站
切换语言
简体中文
繁体中文
首页 > 资讯 > 正文

Tradingview双均线策略编写

2021-11-15 10:17:35
 
885

根据移动均线指标复制,设定对应的均线将周期,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上面设置不了先出价格

声明:
本文内容不代表斑马投诉网站观点,内容仅供参考,不构成投资建议。投资有风险,选择需谨慎! 如涉及内容、版权等问题,请联系我们,我们会在第一时间作出调整!

相关文章