简体   繁体   中英

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

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

You can plot with valuewhen.

Example: 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:
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(condition ? value : na) // if condition, then plot value, else plot na (like null)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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