title: Capturing Opening price at a specific time
body: <p>Good evening all,</p>
  <p>My first post so please bear with me.</p>
  <p>Capture price open at a certain time to replicate another time zone opening (represented by a line for the next 24 hours).</p>
  <p>Currently using the below but that is fixed to UTC</p>
  <pre><code>dOpen = security(syminfo.tickerid, &quot;D&quot;, open, lookahead = barmerge.lookahead_on)
  </code></pre>
  <p>[Current dOpen set to security UTC][1]
  I am after being able to select another time for my dOpen.</p>
  <p>Currently have the above setup to use UTC, but am intrigued to see if I can replicate it for other time zones.</p>
  <p>I have been reading a lot but don't seem to be able to find the right material to assist me.
  Any guidance will be gratefully received.</p>
  <p>Edit Update 29/01/2021
  I have done some homework and have the below, but I think that its not as clean as it should be. I would be grateful if someone could cast their eyes over it and offer some suggestions.</p>
  <pre><code>//@version=4
  study(&quot;Timed Open&quot;, overlay=true)
  
  offset_val = input(title=&quot;Label Offset&quot;, type=input.integer, defval=20)
  
  LonOpenInput = input('0800-0801:1234567', title=&quot;London&quot;) //set the opening range you are interested in
  NYOpenInput = input('1300-1301:1234567', title=&quot;New York&quot;) //set the opening range you are interested in
  AsiaOpenInput = input('2300-2301:1234567', title=&quot;Asia&quot;) //set the opening range you are interested in
  
  
  LonOpen = time(timeframe.period, LonOpenInput)
  NYOpen = time(timeframe.period, NYOpenInput)
  AsiaOpen = time(timeframe.period, AsiaOpenInput)
  
  var LonOpenPA = 0.0
  if LonOpen
      if not LonOpen[1]
          LonOpenPA := open
      else
          LonOpenPA := max(open, LonOpenPA)
  
  var NYOpenPA = 0.0
  if NYOpen
      if not NYOpen[1]
          NYOpenPA := open
      else
          NYOpenPA := max(open, NYOpenPA)
  
  var AsiaOpenPA = 0.0
  if AsiaOpen
      if not AsiaOpen[1]
          AsiaOpenPA := open
      else
          AsiaOpenPA := max(open, AsiaOpenPA)
  
  
  plot(not LonOpen ? LonOpenPA : na, title=&quot;London Open&quot;, color=color.yellow, linewidth=1, style=plot.style_linebr)
  plotshape(LonOpenPA, style=shape.labeldown, location=location.absolute, color=color.yellow,  textcolor=color.white, show_last=1, text=&quot;London Open&quot;,  offset = offset_val, transp=20, title=&quot;London Open&quot;)
  
  plot(not NYOpen ? NYOpenPA : na, title=&quot;New York Open&quot;, color=color.blue, linewidth=1, style=plot.style_linebr)
  plotshape(NYOpenPA, style=shape.labeldown, location=location.absolute, color=color.blue,  textcolor=color.white, show_last=1, text=&quot;New York Open&quot;,  offset = offset_val, transp=20, title=&quot;New York Open&quot;)
  
  
  plot(not AsiaOpen ? AsiaOpenPA : na, title=&quot;Asia Open&quot;, color=color.orange, linewidth=1, style=plot.style_linebr)
  plotshape(AsiaOpenPA, style=shape.labeldown, location=location.absolute, color=color.orange,  textcolor=color.white, show_last=1, text=&quot;Asia Open&quot;,  offset = offset_val, transp=20, title=&quot;Asia Open&quot;)
  </code></pre>
  <p>Edit Update 30/01/2021 @ 1400</p>
  <p>Updated script to capture Daily and weekly market opening times and applied suggested comments from @AnyDozer</p>
  <pre><code>//@version=4
  study(&quot;Help (Timed Open) - DozerAssit&quot;, overlay=true)
  
  offset_val = input(title=&quot;Label Offset&quot;, type=input.integer, defval=30)
      
  LonDOpenInput = input('0800-0801:134567', title=&quot;London Daily Open&quot;) //set the opening range you are interested in
  LonWOpenInput = input('0800-0801:2', title=&quot;London Weekly Open&quot;) //set the opening range you are interested in
  
  NYDOpenInput = input('1300-1301:134567', title=&quot;New York Daily Open&quot;) //set the opening range you are interested in
  NYWOpenInput = input('1300-1301:2', title=&quot;New York Weekly Open&quot;) //set the opening range you are interested in
  
  AsiaDOpenInput = input('2300-2301:134567', title=&quot;Asia Daily Open&quot;) //set the opening range you are interested in
  AsiaWOpenInput = input('2300-2301:2', title=&quot;Asia Weekly Open&quot;) //set the opening range you are interested in
  
  
  LonDOpen = time(&quot;1&quot;, LonDOpenInput)
  LonWOpen = time(&quot;1&quot;, LonWOpenInput)
  
  NYDOpen = time(&quot;1&quot;, NYDOpenInput)
  NYWOpen = time(&quot;1&quot;, NYWOpenInput)
  
  AsiaDOpen = time(&quot;1&quot;, AsiaDOpenInput)
  AsiaWOpen = time(&quot;1&quot;, AsiaWOpenInput)
  
  var LonDOpenPA = 0.0
  if LonDOpen
      if not LonDOpen[1]
          LonDOpenPA := open
  
  var LonWOpenPA = 0.0
  if LonWOpen
      if not LonWOpen[1]
          LonWOpenPA := open
  
  
  var NYDOpenPA = 0.0
  if NYDOpen
      if not NYDOpen[1]
          NYDOpenPA := open
      
  var NYWOpenPA = 0.0
  if NYWOpen
      if not NYWOpen[1]
          NYWOpenPA := open
  
  
  var AsiaDOpenPA = 0.0
  if AsiaDOpen
      if not AsiaDOpen[1]
          AsiaDOpenPA := open
      
  var AsiaWOpenPA = 0.0
  if AsiaWOpen
      if not AsiaWOpen[1]
          AsiaWOpenPA := open
  
  
  
  plot(not LonDOpen ? LonDOpenPA : na, title=&quot;London D Open&quot;, color=color.yellow, linewidth=1, style=plot.style_linebr)
  plotshape(LonDOpenPA, style=shape.labeldown, location=location.absolute, color=color.yellow,  textcolor=color.white, show_last=1, text=&quot;London D Open&quot;,  offset = offset_val, transp=20, title=&quot;London D Open&quot;)
  plot(not LonWOpen ? LonWOpenPA : na, title=&quot;London W Open&quot;, color=color.yellow, linewidth=2, style=plot.style_linebr)
  plotshape(LonWOpenPA, style=shape.labeldown, location=location.absolute, color=color.yellow,  textcolor=color.white, show_last=1, text=&quot;London W Open&quot;,  offset = offset_val, transp=20, title=&quot;London W Open&quot;)
  
  
  plot(not NYDOpen ? NYDOpenPA : na, title=&quot;New York D Open&quot;, color=color.blue, linewidth=1, style=plot.style_linebr)
  plotshape(NYDOpenPA, style=shape.labeldown, location=location.absolute, color=color.blue,  textcolor=color.white, show_last=1, text=&quot;New York D Open&quot;,  offset = offset_val, transp=20, title=&quot;New York D Open&quot;)
  plot(not NYWOpen ? NYWOpenPA : na, title=&quot;New York W Open&quot;, color=color.blue, linewidth=2, style=plot.style_linebr)
  plotshape(NYWOpenPA, style=shape.labeldown, location=location.absolute, color=color.blue,  textcolor=color.white, show_last=1, text=&quot;New York W Open&quot;,  offset = offset_val, transp=20, title=&quot;New York W Open&quot;)
  
  
  plot(not AsiaDOpen ? AsiaDOpenPA : na, title=&quot;Asia D Open&quot;, color=color.orange, linewidth=1, style=plot.style_linebr)
  plotshape(AsiaDOpenPA, style=shape.labeldown, location=location.absolute, color=color.orange,  textcolor=color.white, show_last=1, text=&quot;Asia D Open&quot;,  offset = offset_val, transp=20, title=&quot;Asia D Open&quot;)
  plot(not AsiaWOpen ? AsiaWOpenPA : na, title=&quot;Asia W Open&quot;, color=color.orange, linewidth=2, style=plot.style_linebr)
  plotshape(AsiaWOpenPA, style=shape.labeldown, location=location.absolute, color=color.orange,  textcolor=color.white, show_last=1, text=&quot;Asia W Open&quot;,  offset = offset_val, transp=20, title=&quot;Asia W Open&quot;)
  </code></pre>
  <p>I have come across the below but am having issues implementing it (still playing),</p>
  <pre><code>onlyLastperiode = input (title=&quot;show only last periode&quot;, type=input.bool , defval=false) 
  closeTime = security(syminfo.tickerid, &quot;D&quot;, time_close[0], lookahead=true)
  paintitNot = timenow &gt; (closeTime + (24*60*1000*60))
  </code></pre>
  <p>How to implement this to the plot ----</p>
  <pre><code>onlyLastperiode and paintitNot
  </code></pre>