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

huangapple go评论44阅读模式
英文:

In Pine Script can I detect a line crossover?

问题

I have a line in Pine Script:

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

我有一行Pine Script代码:

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

How can I detect that price has crossed the baseline?

我如何检测价格是否已经穿过了基线?

isCrossed = ta.crossover(high, baseline)

The line above results in the following error:

上面的代码导致了以下错误:

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

无法使用参数 'source2'='baseline' 调用 'ta.crossover'。使用了 'series line' 类型的参数,但期望的是 'series float'。

英文:

I have a line in Pine Script:

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

How can I detect that price has crossed the baseline?

isCrossed = ta.crossover(high, baseline)

The line above results in following error:

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

答案1

得分: 1

In your example y2 is the end of the line. If your x2 is the bar_index (we can't see because we don't have your entire code), you can use:

isCrossed = ta.crossover(high, y2)
英文:

In you example y2 is the end of the line. If your x2 is the bar_index (we can't see because we don't have your entire code), you can use :

isCrossed = ta.crossover(high, y2)

huangapple
  • 本文由 发表于 2023年5月6日 18:26:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76188384.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定