查找过去几支蜡烛中是否越过移动平均
目前我手动交易并使用交易量作为额外的汇合。如果过去的几个成交量柱中的任何一个超过了移动平均线,并且同时(长时间)形成了一根红色蜡烛,那么这是一个积极的信号。
我正在尝试在 pinescript 中重新创建它,但它没有做我希望的事情
这就是我到目前为止所拥有的:
volume_cross(lookbackLength, maLength) =>
for offset = 0 to lookbackLength - 1
volumeMa=ta.sma(volume[offset],maLength)
if ta.crossover(volumeMa,volume[offset]) and close[offset]<open[offset]
true
plotchar(volume_cross(5,20), title="volume_cross")
我是 pinescript 的新手,我之前没有编写过函数,甚至没有编写过循环!
它不仅没有做我希望的事情,而且我收到警告,应该在每次计算时调用 ta 函数,所以我认为有更好的方法来做到这一点
任何帮助将不胜感激
Currently I trade manually and use volume as an extra confluence. If any of the past few volume bars have gone over the moving average and at the same time (for a long) printed a red candle then that's a positive.
I'm trying to recreate this in pinescript, but it's not doing what i'd hope
This is what I have so far:
volume_cross(lookbackLength, maLength) =>
for offset = 0 to lookbackLength - 1
volumeMa=ta.sma(volume[offset],maLength)
if ta.crossover(volumeMa,volume[offset]) and close[offset]<open[offset]
true
plotchar(volume_cross(5,20), title="volume_cross")
I'm new to pinescript and i've not written a function or even a loop in this before!
Not only is it not doing what I hope but i'm getting warnings that the ta functions should be called on each calculation, so I assume there's a better way to do this
Any help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
ta.barss()
来弄清楚自音量平均移动平均值以来的最后一次。You can use
ta.barssince()
to figure out when was the last time since volume has crossed moving average.