Question: I have a pine script to draw previous day high/open/low as shown below:

```
//@version=4
strategy("Plot Lines", overlay=true)

PDH = security(syminfo.tickerid,"D",high)
PDO = security(syminfo.tickerid,"D",open)
PDL = security(syminfo.tickerid,"D",low)

plot(PDH, title="High",color=color.red,linewidth=2,trackprice=true)
plot(PDO, title="Open",color=color.yellow,linewidth=2,trackprice=true)
plot(PDL, title="Low",color=color.green,linewidth=2,trackprice=true)

```

The script work well but I only want previous day to be shown and ignore the others day before previous day so that the chart will not be that messy.

This is what I get from the script above:
[![enter image description here](https://i.stack.imgur.com/sVIs9.png)](https://i.stack.imgur.com/sVIs9.png)

As you can see, it plot the PDH/PDO/PDL for every previous day, but I just want previous day (one day) only. Any help or advice will be greatly appreciated!

**New Edited**
[![enter image description here](https://i.stack.imgur.com/Nsez0.png)](https://i.stack.imgur.com/Nsez0.png)

**Result after apply the script**
[![enter image description here](https://i.stack.imgur.com/uKXjz.png)](https://i.stack.imgur.com/uKXjz.png)

Answer: 
You can use the `line()` function instead of `plot()`.

Draw the lines if it is the last bar, and delete the previous ones along the way.

```
//@version=4
study("Plot Lines", overlay=true)

PDH = security(syminfo.tickerid,"D",high)
PDO = security(syminfo.tickerid,"D",open)
PDL = security(syminfo.tickerid,"D",low)

var line l_pdh = na, var line l_pdo = na, var line l_pdl = na

if barstate.islast
    l_pdh := line.new(bar_index-1, PDH, bar_index, PDH, extend=extend.both, color=color.green)
    l_pdo := line.new(bar_index-1, PDO, bar_index, PDO, extend=extend.both, color=color.blue)
    l_pdl := line.new(bar_index-1, PDL, bar_index, PDL, extend=extend.both, color=color.red)

line.delete(l_pdh[1])
line.delete(l_pdo[1])
line.delete(l_pdl[1])

```

[![enter image description here](https://i.stack.imgur.com/FIjW9.png)](https://i.stack.imgur.com/FIjW9.png)
Not exactly what you asked, but it could lead you in the right direction:

```js
//@version=5
indicator("My script", overlay = true)

resolution = 'D'
var float highSecurityValue   = na
var float lowSecurityValue    = na
var float closeSecurityValue  = na

fNoRepainting(timeframe, expression) =>
    request.security(symbol = syminfo.tickerid, timeframe = timeframe, expression = expression[barstate.isrealtime ? 1 : 0], gaps = barmerge.gaps_off)[barstate.isrealtime ? 0 : 1] // PineCoders best practice.

trimLineAtRange = '0000-0001'
trimLinePlot = time('1', trimLineAtRange)
plottingCondition = not trimLinePlot

highRequest  = fNoRepainting(resolution, high)
lowRequest   = fNoRepainting(resolution, low)
closeRequest = fNoRepainting(resolution, close)
if trimLinePlot[1]
    highSecurityValue := highRequest
    lowSecurityValue := lowRequest
    closeSecurityValue := closeRequest

plot(plottingCondition ? highSecurityValue : na, title = 'H', style = plot.style_linebr, linewidth = 1, color = color.new(color.red, 0))
plot(plottingCondition ? lowSecurityValue : na, title = 'L', style = plot.style_linebr, linewidth = 1, color = color.new(color.lime, 0))
plot(plottingCondition ? closeSecurityValue : na, title = 'C', style = plot.style_linebr, linewidth = 1, color = color.new(color.orange, 0))

```

The result is (maybe a little more than your asked):

[![enter image description here](https://i.stack.imgur.com/ljG6p.png)](https://i.stack.imgur.com/ljG6p.png)

I placed the vertical lines just to enhance the division of days.

Notice that the horizontal line of each day, belongs to the value of the previous day. Green is `low`est, red is `high`est, and orange is `close` (you can change it for `open`, but I do recommend you to use the closing value).