PINE脚本:添加两个股票音量值
我正在尝试计算两只股票的总成交量并绘制它。其中一只于 2022 年开始交易,另一只于 2021 年开始交易。我注意到情节从 2022 年开始,跳过了 2021 年第一支股票的交易量。
indicator("tasi_p1", overlay=false,format=format.volume)
src = request.security("TADAWUL:4164",timeframe.period,volume, barmerge.gaps_off)
src := src +
request.security("TADAWUL:2082",timeframe.period,volume, barmerge.gaps_off)
palette = close[1] > close ? color.red : color.green
plot(src,style=plot.style_histogram,color = palette)
我的主要目标是绘制相关股票组/行业的交易量并将其用于我的策略。
另外,我注意到在 TradingView 中添加股票代码(例如“4164 + 2082”)时,TradingView 中也有相同的行为,它会跳过 2021 年部分,甚至在蜡烛图中。
有错误还是我遗漏了什么?
I am trying to take the total volume of two stocks and plot it. One of them started trading in 2022 and the other in 2021. I noticed the plot starts from 2022 skipping the volume for first stock in 2021.
indicator("tasi_p1", overlay=false,format=format.volume)
src = request.security("TADAWUL:4164",timeframe.period,volume, barmerge.gaps_off)
src := src +
request.security("TADAWUL:2082",timeframe.period,volume, barmerge.gaps_off)
palette = close[1] > close ? color.red : color.green
plot(src,style=plot.style_histogram,color = palette)
My main goal is to plot the volume of group/sector of related stocks and use it in my strategy.
Also, I noticed same behavior in TradingView when adding the stock symbols in Symbol Search text field like "4164 + 2082" it skips 2021 part even the in candle chart.
Is there a bug or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,因为
4164
将在开始交易之前返回NaN
作为其交易量。然后您尝试在计算中使用此NaN
值,但您不应该这样做。将您的
src
包装到nz()
中,它将用零替换NaN
。Well, because
4164
will returnNaN
as its volume before it started trading. Then you are trying to use thisNaN
value in your calculations which you shouldn't do.Wrap your
src
intonz()
and it will replaceNaN
with zeros.