pine-script - Tradingview 仅显示上周 Quandl CFTC 数据
问题描述
我正在使用 pine 脚本将 CFTC COT 数据提取到我的指标中。但是,我注意到最新一行数据从未从 CFTC 中提取 - 该指标仅显示上周的数据。
CFTC 数据在美国东部标准时间每周五下午 3:30 发布。我在周六查看这些数据 - 所以我期待看到昨天报告中发布的数据。
这是我正在使用的脚本(如果我在 pine 脚本的安全功能中使用 resolution=D 或 W,结果不会改变)
//@version=4
study("COT data bug", shorttitle="Bug demo", precision=0)
qticker =
syminfo.root == "ES" ? "13874A" :
syminfo.root == "NQ" ? "209742" :
syminfo.root == "RTY" ? "239742":
syminfo.root == "YM" ? "124603" :
syminfo.root == "ZN" ? "043602" :
syminfo.root
cot = "QUANDL:CFTC/" + qticker + "_FO_ALL|"
oi = security(cot + "0", "W", close)
asset_mgr_lg = security(cot + "4", "W", close)
asset_mgr_sh = security(cot + "5", "W", close)
plot(oi, title="Open Interest", color=color.black) // output=232,089, expected=230,513
plot(asset_mgr_lg, title="asset_mgr_lg", color=color.blue) // output=71,131, expected=65,170
plot(asset_mgr_sh, title="asset_mgr_sh", color=color.red) // output=29,288, expected=31,260
有没有其他人也遇到过这个问题?任何潜在的解决方案?
谢谢!
解决方案
要尝试的一件事是lookahead=barmerge.lookahead_on
在您的security()
通话中使用。这可能会解决实时柱中的问题,但 OTOH 会让您的调用使用历史柱上的未来数据,您需要使用当前使用的表格来避免前瞻偏差。
如果使用前瞻确实是解决方案,您可以使用如下代码:
oiH = security(cot + "0", "W", close)
asset_mgr_lgH = security(cot + "4", "W", close)
asset_mgr_shH = security(cot + "5", "W", close)
oiR = security(cot + "0", "W", close, lookahead = barmerge.lookahead_on)
asset_mgr_lgR = security(cot + "4", "W", close, lookahead = barmerge.lookahead_on)
asset_mgr_shR = security(cot + "5", "W", close, lookahead = barmerge.lookahead_on)
oi = 0.
asset_mgr_lg = 0.
asset_mgr_sh = 0.
if barstate.islast
oi := oiR
asset_mgr_lg := asset_mgr_lgR
asset_mgr_sh := asset_mgr_shR
else
oi := oiH
asset_mgr_lg := asset_mgr_lgH
asset_mgr_sh := asset_mgr_shH
推荐阅读
- java - 为什么只有 show() 操作出现在 spark ui 中?
- android - 未处理异常:DatabaseException(Error Domain=FMDatabase Code=26 "file is not a database"。更新到 Flutter 2.0 后
- flutter - 在为我的应用添加图标时在 pubspec.yaml 中获取此异常
- c# - 如何以另一种形式将我的数据网格视图项显示到文本框?
- prometheus - 使用流入数据库的 grafana+prometheus
- jquery - 无法在 jQuery AJAX 500 中保存关系数据(内部服务器错误)
- bash - 让 certbot 等待另一个实例
- css - css flex布局中有空格
- kubernetes - 从集群内访问主机时,Kubernetes ingress-nginx 失败
- docker - GCP 上的 Docker 持久卷