title: How to draw a vertical line in TradingView pine script?
body: <p>I'm trying to use the web based <a href="https://www.tradingview.com/" rel="nofollow noreferrer">TradingView</a> platform to make my own custom scripts to display various financial market properties. This is possible through its <a href="https://www.tradingview.com/wiki/Category:Pine_Script" rel="nofollow noreferrer">pine</a> scripting engine/interpreter. </p>
  
  <p>At the moment I'm trying to simply display a vertical line on either the main chart or on an indicator chart. However, it doesn't seem that their scripting engine is supporting vertical lines, except by using the plot's <code>histogram</code> or <code>column</code> types. Either way, I am not able to get any satisfactory lines. </p>
  
  <hr>
  
  <p><strong>SOME TESTS</strong></p>
  
  <p><strong>(1)</strong> I've had some minor success with using <code>bgcolor()</code> like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>//@version=3
  study(title="vbar1", overlay = false)
  trange(res, sess) =&gt; not na(time(res, sess))
  vlinecol = #000000 // black
  plot(n, color = na) // check last value from plot but don't display
  vline =  (n &lt; 5710) ? na : trange("1", "0700-0701") ? vlinecol : na
  bgcolor(vline, transp=0)
  </code></pre>
  
  <p>This results in:</p>
  
  <p><a href="https://i.stack.imgur.com/je9jF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/je9jF.png" alt="enter image description here"></a></p>
  
  <p><strong>(2)</strong> A much better result when using <code>plot()</code> with the <code>style=histogram</code> argument:</p>
  
  <pre class="lang-java prettyprint-override"><code>//@version=3
  study(title="vbar2", overlay = true) // scale=scale.none only for overlay=true
  vlinecol = #000000 // black
  cond = barstate.islast
  bh = 10*high   // Use 10 x the window max price height for top of vbar (or use 1e20)
  bo = -10       // Set offset from last bar
  plot(cond ? bh : na, color=vlinecol, linewidth=2, offset=bo, style = histogram, transp=0)
  </code></pre>
  
  <p>with the following result:</p>
  
  <p><a href="https://i.stack.imgur.com/BNjcv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BNjcv.png" alt="enter image description here"></a></p>