I want to create an indicator that draws a horizontal line showing the daily last closing price and the line auto adjusts daily.
I'm expecting something like these:
Daily Last Close Line:
Daily Last Close visible on lower timeframe:
I want to create an indicator that draws a horizontal line showing the daily last closing price and the line auto adjusts daily.
I'm expecting something like these:
Daily Last Close Line:
Daily Last Close visible on lower timeframe:
You should try this :
//@version=5
indicator("Yesterday Close", overlay=true)
indexHighTF = barstate.isrealtime ? 1 : 0
indexCurrTF = barstate.isrealtime ? 0 : 1
yesterday_close = request.security(syminfo.tickerid, "1D",
close[indexHighTF])[indexCurrTF]
daily_line = line.new(bar_index, yesterday_close , bar_index-1, yesterday_close, extend= extend.both, color=color.yellow)
line.delete(daily_line[1])
It is based on the pinescript manual , see here : https://www.tradingview.com/pine-script-reference/v5/#fun_request{dot}security