简体   繁体   English

在 Pine Script 中满足条件时,如何在关闭栏上画一条线?

[英]How to draw a line on the bar close when the condition is met in Pine Script?

满足条件时,如何在收盘价上连续画一条线?

You can plot with valuewhen.您可以使用 valuewhen 进行绘图。

Example: condition=ta.cross(ta.sma(close,20),ta.sma(close,50)) v=ta.valuewhen(condition,close,0) plot(v)示例:condition=ta.cross(ta.sma(close,20),ta.sma(close,50)) v=ta.valuewhen(condition,close,0) plot(v)

Can you explain further, what exactly you want to do?你能进一步解释一下,你到底想做什么?

  • If you want to draw a line from one point, to another you can use line.new() , which could look like this:如果你想从一个点画一条线到另一个点,你可以使用line.new() ,它看起来像这样:
if condition
  line.new(x1, y1, x2, y2)
  • If you want to draw a series on a given condition you can use plot() and the ternary operator ?: , which could look like this:如果要在给定条件下绘制系列,可以使用plot()和三元运算符?: ,如下所示:
plot(condition ? value : na) // if condition, then plot value, else plot na (like null)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM