I tried this code but it produced the line too long and I couldn’t find an ability within the plot function to shorten the length of the line to the desired effect
<code>//@version=5
indicator(title="Time points", shorttitle="Tp", overlay=true)
UTCTimeInput = input('1807-1808', title="Dam")
OpenValueTime = time("1", UTCTimeInput)
var OpenPA = 0.0
if OpenValueTime
if not OpenValueTime[1]
OpenPA := open
plot(not OpenValueTime ? OpenPA : na, title="time point", color=color.black,
linewidth=2, style=plot.style_linebr)
</code>
<code>//@version=5
indicator(title="Time points", shorttitle="Tp", overlay=true)
UTCTimeInput = input('1807-1808', title="Dam")
OpenValueTime = time("1", UTCTimeInput)
var OpenPA = 0.0
if OpenValueTime
if not OpenValueTime[1]
OpenPA := open
plot(not OpenValueTime ? OpenPA : na, title="time point", color=color.black,
linewidth=2, style=plot.style_linebr)
</code>
//@version=5
indicator(title="Time points", shorttitle="Tp", overlay=true)
UTCTimeInput = input('1807-1808', title="Dam")
OpenValueTime = time("1", UTCTimeInput)
var OpenPA = 0.0
if OpenValueTime
if not OpenValueTime[1]
OpenPA := open
plot(not OpenValueTime ? OpenPA : na, title="time point", color=color.black,
linewidth=2, style=plot.style_linebr)
I tired calling line.set.xy1 and xy2 as per below but it didn’t plot anything.
<code>indicator(title="Time Points", shorttitle="TPs", overlay=true)
starttime = time('1807')
endtime = time('1901')
var float priceLevel = na
if (time >= starttime and time <= endtime)
priceLevel := open
var line horizontalLine = na
if (na(horizontalLine) and not na(priceLevel))
horizontalLine := line.new(starttime, priceLevel, endtime, priceLevel,
color=color.black, width=2)
else if (not na(horizontalLine))
line.set_xy1(horizontalLine, starttime, priceLevel)
line.set_xy2(horizontalLine, endtime, priceLevel)
</code>
<code>indicator(title="Time Points", shorttitle="TPs", overlay=true)
starttime = time('1807')
endtime = time('1901')
var float priceLevel = na
if (time >= starttime and time <= endtime)
priceLevel := open
var line horizontalLine = na
if (na(horizontalLine) and not na(priceLevel))
horizontalLine := line.new(starttime, priceLevel, endtime, priceLevel,
color=color.black, width=2)
else if (not na(horizontalLine))
line.set_xy1(horizontalLine, starttime, priceLevel)
line.set_xy2(horizontalLine, endtime, priceLevel)
</code>
indicator(title="Time Points", shorttitle="TPs", overlay=true)
starttime = time('1807')
endtime = time('1901')
var float priceLevel = na
if (time >= starttime and time <= endtime)
priceLevel := open
var line horizontalLine = na
if (na(horizontalLine) and not na(priceLevel))
horizontalLine := line.new(starttime, priceLevel, endtime, priceLevel,
color=color.black, width=2)
else if (not na(horizontalLine))
line.set_xy1(horizontalLine, starttime, priceLevel)
line.set_xy2(horizontalLine, endtime, priceLevel)
New contributor
shaddy ghazal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.