我怎样才能让这个时间范围脚本正常工作,因为它抛出随机数
我有下面的脚本。这个想法是,它将跟踪并绘制当天的累计交易量(然后在新会话开始时重置为 0),
第二部分将通过获取过去 10 天的平均交易量(来自每日交易量)来获取股票的平均交易量 。 )
最后因为我想知道 SPY 相对于前 10 天的表现如何(是否为 12:00 时平均交易量的 100% 等),我认为该图会做到这一点,但它抛出了一些随机数并且峰值,因为应该有一个实例,除了在一天结束/一天开始之外,它会下降,
//@version=5
indicator('VOl calc Lines', '',false)
tf=input(title="Period",defval=10)//10 days
////////////////////////////////////////////////////////////////////////////////cumulative volume for the day
todayvol() =>
cumTimeFrame = input.timeframe('D')
is_new_day = ta.change(time(cumTimeFrame)) != 0 ? 1 : 0
cnt_new_day = ta.barssince(is_new_day)and barstate.isrealtime and session.ismarket
var todayvol1 = 0.0
todayvol1 := volume + (is_new_day ? 0 : todayvol1)
////////////////////////////////////////////////////////////////////////////////volume average over 10 days (tf)
dailyvolav()=>
cumTimeFrame = input.timeframe('D')
is_new_day = ta.change(time(cumTimeFrame)) != 0 ? 1 : 0
cnt_new_day = ta.barssince(is_new_day)and barstate.isrealtime and session.ismarket
var todayvol11 = 0.0
todayvol11 := volume + (is_new_day ? 0 : todayvol11)
ta.sma(todayvol11,tf)
plot(request.security("SPY", "5",(dailyvolav()/todayvol())*100))
我一直在研究这个问题,但似乎仍然找不到问题。当我在股票行情和时间范围为 1D 时,它似乎有效,但在 5 分钟时间范围内不起作用。数字全错了
I have the below script. the idea is that it will track and plot the accumulative volume for the day ( then reset to 0 when the new session starts)
the second part will then take the average volume for the ticker by taking the last 10 days average volume (from the daily)
finally because I want to know how SPY is doing relatively to the previous 10 days (is it at 100% of the average volume at 12:00 etc )which I thought the plot would do however it is throwing up some random numbers and spikes where as there should nexer be an instance where this drops other than at the end of the day/ start of the day
//@version=5
indicator('VOl calc Lines', '',false)
tf=input(title="Period",defval=10)//10 days
////////////////////////////////////////////////////////////////////////////////cumulative volume for the day
todayvol() =>
cumTimeFrame = input.timeframe('D')
is_new_day = ta.change(time(cumTimeFrame)) != 0 ? 1 : 0
cnt_new_day = ta.barssince(is_new_day)and barstate.isrealtime and session.ismarket
var todayvol1 = 0.0
todayvol1 := volume + (is_new_day ? 0 : todayvol1)
////////////////////////////////////////////////////////////////////////////////volume average over 10 days (tf)
dailyvolav()=>
cumTimeFrame = input.timeframe('D')
is_new_day = ta.change(time(cumTimeFrame)) != 0 ? 1 : 0
cnt_new_day = ta.barssince(is_new_day)and barstate.isrealtime and session.ismarket
var todayvol11 = 0.0
todayvol11 := volume + (is_new_day ? 0 : todayvol11)
ta.sma(todayvol11,tf)
plot(request.security("SPY", "5",(dailyvolav()/todayvol())*100))
I have working on this and still cant seem to find the issue. it seems to work when im on the ticker and timeframe is 1D but dosent work on the 5 min time frame. the figures are all wrong
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了答案,这是由于没有在安全调用中命名经纪人(当你知道时很明显)
I have found the answer, it is due to not naming the broker in the security call (obvious when you know)