我怎样才能让这个时间框架脚本正常工作,因为它会抛出随机数

How can I get this timeframe script to work properly as it is throwing out random numbers

我有以下脚本。这个想法是它将跟踪并绘制当天的累积交易量(然后在新会话开始时重置为 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 分钟时间范围内工作时它似乎工作。数字全错了

我找到了答案,这是因为没有在安全调用中命名代理(当你知道时很明显)