0
votes

The code below draws the Last Price Line/ line for the last traded price. It uses the line.new() function to create the line. How do I draw the same line using the plot() function?

//@version=4
study("My Script", overlay=true)

var line lastPriceLine = line.new(0, 0, 0, 0)
line.set_xy1(lastPriceLine, bar_index-50, close)
line.set_xy2(lastPriceLine, bar_index, close)

enter image description here

1

1 Answers

0
votes

Do you mean Last Traded price of the prior / previous day?

if so,

//@version=4
study("LTP", overlay = true)
getseries(val,TF,offset)=>
    VAL = security(syminfo.tickerid, TF, val[offset], false, true)

LTP = getseries(close,'D',1)         // 1 signifies the previous day
plot(LTP)