0
votes

I need help with pinescript on Tradingview.com I need to plot horizontal lines on the high and low of previous 2 days price. This needs to remain the same no matter which timeframe I am seeing the chart in. ie: 1 min, 5 min, 1 day etc.

Can someone please help?

Thanks!

1
Welcome to SO! Can you share what you have tried so far? see here - jayveesea

1 Answers

1
votes
//2 days High Low Box
study(title="2 days High Low Box", shorttitle="High Low Box, overlay=true)
st = input(true, title="Show Todays OHLC?")
//sy = input(false, title="Show Yesterdays OHLC?")

//Daily
ph = security(tickerid, 'D', high[2])
//pdh = security(tickerid, 'D', high[1])
pl = security(tickerid, 'D', low[2])
//pdl = security(tickerid, 'D', low[1])
plot(st and ph ? ph : na, title="2 Days High", style=line, linewidth=1, color=blue)
plot(st and pl ? pl : na, title="2 Days Low", style=line, linewidth=1, color=red)