Pine script 如何利用tradingview回溯测试中的安全功能解决历史与实时数据问题

Pine script 如何利用tradingview回溯测试中的安全功能解决历史与实时数据问题,pine-script,Pine Script,我真的很难在回溯测试中使用我的指标,因为它在达到它们之前就绘制了未来的每日高点和低点。根据pine脚本,这应该可以解决问题: // To avoid difference in the calculation on history/realtime you can request // not the latest values and use merge strategy flags as follows: s2=security(tickerid, "D", close[1], barmer

我真的很难在回溯测试中使用我的指标,因为它在达到它们之前就绘制了未来的每日高点和低点。根据pine脚本,这应该可以解决问题:

// To avoid difference in the calculation on history/realtime you can request
// not the latest values and use merge strategy flags as follows:
s2=security(tickerid, "D", close[1], barmerge.gaps_off, barmerge.lookahead_on)
但我已经做到了,我得到了同样的结果。有没有人对这类问题有经验?非常感谢,谢谢

已尝试tradingview解决方案,并在barmerge打开和关闭之间切换

  //Intraday Highs and Lows
highestHigh = security(tickerid, "D", high[1],barmerge.gaps_off,barmerge.lookahead_on)
lowestLow   = security(tickerid, "D", low[1],barmerge.gaps_off, barmerge.lookahead_on)
//Intraday Highs and Lows Delayed
highestHighD = security(tickerid, "D",high[2],barmerge.gaps_off,barmerge.lookahead_on)
lowestLowD   = security(tickerid, "D", low[2],barmerge.gaps_off,barmerge.lookahead_on)
//4HR Highs and Lows Delayed
daily_high = security(tickerid, "240" , high[1],barmerge.gaps_off,barmerge.lookahead_on)
daily_low = security(tickerid, "240", low[1],barmerge.gaps_off,barmerge.lookahead_on)

根据trading view,结果应该用第一个代码固定,我的每日值将随着交易的进行而自动更新,而不考虑未来的值,但实际结果只是在会话开始时自动绘制日内高点和低点

如果您提到运行脚本的符号/TF,并提供正在使用的
plot()
调用,则会有所帮助。您展示的第一个示例应该是有效的。此PineCoders显示图表上绘制的
security()
调用的所有组合,可能会有所帮助。我不知道tradingview解决方案,但这是回测时的常见问题。一些回溯测试提供了在交易结束前执行交易的能力。但这在实时交易中是不可能的。因为只有当它完成时,你才能得到酒吧。试着在你的回溯测试中使用上一条