英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论