`pivothigh` 对于 1D 具有不一致的结果

问题描述 投票:0回答:1

非 1 天的图表时间范围上的

request.security(syminfo.tickerid, "D", ta.pivothigh(i_leftBars, 10))
显示与当前图表处于 1 天时间范围时的
ta.pivothigh(i_leftBars, 10)
不同的枢轴日期。有没有办法让枢轴高点(和枢轴低点)显示在同一天?我的目标是使用枢轴日期来锚定 VWAP 线。

这是代码:

//@version=5
indicator("DEBUG: Pivot High and Low", overlay=true)

i_leftBars = input(10, title="Bars to the Left")
i_rightBars = input(10, title="Bars to the Right")

ph = ta.pivothigh(i_leftBars, i_rightBars)
pl = ta.pivotlow(i_leftBars, i_rightBars)

phD = request.security(syminfo.tickerid, "D", ta.pivothigh(i_leftBars, i_rightBars))
plD = request.security(syminfo.tickerid, "D", ta.pivotlow(i_leftBars, i_rightBars))

plot(ph, style=plot.style_cross, linewidth=3, color= color.red)
plot(pl, style=plot.style_cross, linewidth=3, color= color.green)
plot(phD, style=plot.style_cross, linewidth=5, color= color.orange)
plot(plD, style=plot.style_cross, linewidth=5, color= color.blue)

这是 4 小时时间范围内的输出。 https://www.tradingview.com/x/T8Z71wbw/

枢轴甚至不会在同一天落地。有什么建议吗

request pivot pine-script pine-script-v5
1个回答
0
投票

您可以在请求函数中使用前瞻。 请阅读本文以了解有关前瞻的更多信息。(非常重要) https://www.tradingview.com/pine-script-docs/en/v5/concepts/Other_timeframes_and_data.html#lookahead

此外,您还可以使用一个请求从同一交易品种和时间范围获取所需的所有数据。

此外,我还打开了请求函数中的间隙。 请参阅此了解更多信息: https://www.tradingview.com/pine-script-docs/en/v5/concepts/Other_timeframes_and_data.html#gaps

您可以更改前瞻和间隙参数以查看图表上的效果。

抱歉,我的英语无法帮助我进行更多解释。

//@version=5
indicator("DEBUG: Pivot High and Low", overlay=true)

i_leftBars = input(10, title="Bars to the Left")
i_rightBars = input(10, title="Bars to the Right")

ph = ta.pivothigh(i_leftBars, i_rightBars)
pl = ta.pivotlow(i_leftBars, i_rightBars)

[phD, plD] = request.security(syminfo.tickerid, "D", [ph, pl], lookahead = barmerge.lookahead_on, gaps = barmerge.gaps_on)

plot(ph, style=plot.style_cross, linewidth=3, color= color.red)
plot(pl, style=plot.style_cross, linewidth=3, color= color.green)
plot(phD, style=plot.style_cross, linewidth=5, color= color.orange)
plot(plD, style=plot.style_cross, linewidth=5, color= color.blue)
© www.soinside.com 2019 - 2024. All rights reserved.