在 Pine Script 中,我可以检测线交叉吗?

我在 Pine Script 中有一行:

baseLine := line.new(x1, y1, x2, y2, width=1, extend=extendStyle, color=color.new(colorLower, 0))

我如何检测价格是否超过了基线?

isCrossed = ta.crossover(high, baseline)

上面的行导致以下错误:

Cannot call 'ta.crossover' with argument 'source2'='baseline'. An argument of 'series line' type was used but a 'series float' is expected.

回答
M
Ms. Gudrun Stiedemann Jr.
3周前

在您的示例中,y2 是该行的结尾。 如果您的 x2 是 bar_index(我们看不到,因为我们没有您的完整代码),您可以使用:

isCrossed = ta.crossover(high, y2)