title: How to draw a vertical line at a certain time in pinescript on Tradingview?
body: <p>I would like to draw a vertical line, every day at a certain local time (e.g. 08:00 GMT+1).</p>
  
  <p>Since my <a href="https://stackoverflow.com/questions/47610638/how-to-draw-a-vertical-line-in-tradingview-pine-script">last post</a> about vertical lines, pine-script has been updated to include <a href="https://www.tradingview.com/script/EmTkvfCM-vline-Function-for-Pine-Script-v4-0/" rel="noreferrer"><code>vline()</code></a>, however, the issue here is getting the time right. Most servers (for FX) seem to be US based and the Trading view local time settings (shown on bottom left) seem totally independent of what is done in pine-script. </p>
  
  <pre class="lang-js prettyprint-override"><code>//@version=4
  study("Time Adjusted Vertical Line", overlay=true)
  
  vline(BarIndex, Color, LineStyle, LineWidth) =&gt; // Verticle Line, 54 lines maximum allowable per indicator
      return = line.new(BarIndex, -1000, BarIndex, 1000, xloc.bar_index, extend.both, Color, LineStyle, LineWidth)
  
  if(bar_index%10==0.0)
      vline(bar_index, #FF8000ff, line.style_solid, 1) // Variable assignment not required
  </code></pre>
  
  <p>I couldn't get the above to work, but I got this to at least show the lines:</p>
  
  <pre class="lang-js prettyprint-override"><code>//@version=4
  study(title="Time Based Session Bars", shorttitle="NowOpen", overlay=true)
  line_height = 2    // We must define a height that reaches far above the highest price level in main chart!
  
  gmt_offs = 2 // GMT + X
  nys_offs = 6 // EST (in GMT)
  
  t1 = time(timeframe.period, "0930-0935:23456")
  //t1 = time(timeframe.isintraday, "0930-0935:23456")
  //t2 = t1 + gmt_offs*60*60*60
  t2 = t1 + 2
  plot(na(t2) ? 0 : line_height, title='Hello!', color=#101010, linewidth=1, style=plot.style_histogram, transp=50, offset=0, trackprice=false)
  </code></pre>
  
  <p>However, the lines are totally wrong: </p>
  
  <p><a href="https://i.stack.imgur.com/T76Jd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/T76Jd.png" alt="enter image description here"></a></p>
  
  <p>How can I extend the above code, to plot a vertical line, every day at a certain time, and get the correct time placement?</p>
  
  <hr>
  
  <p>Possibly Useful links:</p>
  
  <ul>
  <li><p><a href="https://www.tradingview.com/pine-script-docs/en/v4/essential/Sessions_and_time_functions.html" rel="noreferrer">Sessions and time functions</a> (The official Documentation)</p></li>
  <li><p><a href="https://github.com/tradingview/pine_script_docs/blob/master/source/essential/Sessions_and_time_functions.rst" rel="noreferrer">Sessions_and_time_functions</a> (The Github Repo Docs)</p></li>
  <li><p><a href="https://www.tradingview.com/blog/en/introducing-pine-script-4-12626/" rel="noreferrer">Introducing Pine-script-4</a></p></li>
  </ul>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thanks to <em>PineCoders-LucF</em>, I was able to get approximately what I wanted, with the following code:</p>
  
  <pre class="lang-js prettyprint-override"><code>//@version=4
  study("Line at time",overlay=true)
  
  t1 = timestamp("GMT+2", year, month, dayofmonth, 07, 00, 00)
  //t2 = timestamp("GMT+2", year, month, dayofmonth, 10, 00, 00)  // Uncomment this to make a range
  t2=t1                                                           // Comment out this to use a range
  bgcolor( (time &gt;= t1) and (time &lt;= t2) ? color.silver : na, transp = 0)
  </code></pre>
  
  <p>However, there are two issues wit this code. </p>
  
  <ol>
  <li>It doesn't use the nice <code>timeframe.period</code> functionality that allow you to specify certain days and time intervals in one place.  </li>
  <li>It put the line in the "middle" of a candle so if you're on the 1H chart and want a line at 08.00 it will just place it in the middle. Thus not suitable as an alarm/signal, unless you use a &lt;= 1 minute time frame. </li>
  </ol>