You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现box.get_top()与array.get()的实时点数计算?

实现点数(Pips)的实时统计方案

可以实现实时计算,当前代码仅在K线闭合时更新文本的原因是你把box.set_text放在了if barstate.islast判断内。要改为实时更新,只需调整触发逻辑:

修改后的代码片段

t = 0
for i = 0 to array.size(bricks) - 1
    GetBoxTopValue_t = box.get_top(array.get(bricks,i - t))
    GetBoxBotomValue_t = box.get_bottom(array.get(bricks,i - t))
    // 移除barstate.islast判断,让文本在每一次脚本运行时(实时tick)更新
    box.set_text(array.get(bricks,i-t), ' ' + str.tostring(GetBoxTopValue_t - GetBoxBotomValue_t) + ' pips.')
    
    // 保留你的实时删除逻辑
    if high >= GetBoxTopValue_t and low <= GetBoxBotomValue_t
        box.delete(array.get(bricks,i - t))
        array.remove(bricks,i - t)
        t := t + 1

关键说明

  • 移除if barstate.islast后,脚本会在每一个实时tick执行box.set_text,从而实现点数的实时显示。
  • 由于盒子的顶部(box.get_top)和底部(box.get_bottom)值是固定的(除非你动态修改盒子参数),每次计算的差值其实是固定的,但这样修改后会确保文本在盒子存在的整个周期内实时可见,而非仅在K线闭合时才显示。
  • 你的删除逻辑已经支持实时运行,无需改动这部分代码。

内容的提问来源于stack exchange,提问作者tomcraziest

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 00:35:29