79548075

Date: 2025-04-01 08:28:27
Score: 0.5
Natty:
Report link

I have found a solution to my original question.
How 'clean' it is I don't know but it works

Option 1 - Offset each // Lines to Plot

Original

// Lines to Plot
targetTime = timestamp(2025,03,14,06,54,00) 
drawVerticalLine(targetTime)

Solution

targetTime = timestamp(2025,03,14,06,54,00)
offsetTime = targetTime - (time - time[1])
drawVerticalLine(offsetTime)

Option 2 - Offset within // Function drawVerticalLine

// Function drawVerticalLine
drawVerticalLine(targetTime) =>
    line.new (
      x1=targetTime - (time - time[1]) , 
      y1=low, 
      x2=targetTime - (time - time[1]) , 
      y2=high, 
      xloc=xloc.bar_time, 
      extend=extend.both, 
      color=color.new(#f9961e, 10), 
      style=line.style_solid, 
      width=1)  

Logic

calculates the duration of 1 bar time - time[1]

calculates the duration of 2 bars time - time[2]

subtracts 1 bar - (time - time[1])

adds 1 bar + (time - time[1])

adds 2 bars + (time - time[2])

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: user30113140