具体 bar_index 价格提前

Specific bar_index Price ahead

当我们使用 bar_index[1] 时,我们指的是 1 柱前,有没有一种方法可以表示事件后 10 柱?

示例:在 1 月的最高点之后绘制“X”10 根柱。

此外,如果我知道 bar_index 是否可以在 bar_index 1550 获得 high

对于这两种情况,您都可以使用 ta.valuewhen() 函数。

//`bar_index` of the last bar where the `event` was 10 bars ago.    
ta.valuewhen(event[10], bar_index, 0)
    
// `high` of the bar where `bar_index == 1550` was true.
ta.valuewhen(bar_index == 1550, high, 0)

// Alternative method: save value of `high` into a variable when the condition is true
var float h = na
if bar_index == 1550
    h := high