OPEN-SOURCE SCRIPT

Previous Day and Week Levels DDT

//version=5
indicator("Previous Day and Week Levels", overlay=true)

// Get the previous day's high, low, and close
previousDayHigh = request.security(syminfo.tickerid, "D", high[1])
previousDayLow = request.security(syminfo.tickerid, "D", low[1])
previousDayClose = request.security(syminfo.tickerid, "D", close[1])

// Get the previous week's high and low
previousWeekHigh = request.security(syminfo.tickerid, "W", high[1])
previousWeekLow = request.security(syminfo.tickerid, "W", low[1])

// Plotting the previous day's high, low, and close
plot(previousDayHigh, color=color.red, linewidth=2, title="Previous Day High", style=plot.style_line)
plot(previousDayLow, color=color.green, linewidth=2, title="Previous Day Low", style=plot.style_line)
plot(previousDayClose, color=color.blue, linewidth=2, title="Previous Day Close", style=plot.style_line)

// Plotting the previous week's high and low
plot(previousWeekHigh, color=color.purple, linewidth=2, title="Previous Week High", style=plot.style_line)
plot(previousWeekLow, color=color.orange, linewidth=2, title="Previous Week Low", style=plot.style_line)

// Optionally, add labels for visual clarity
label.new(bar_index, previousDayHigh, text="Prev Day High", color=color.red, style=label.style_label_up, yloc=yloc.abovebar)
label.new(bar_index, previousDayLow, text="Prev Day Low", color=color.green, style=label.style_label_down, yloc=yloc.belowbar)
label.new(bar_index, previousDayClose, text="Prev Day Close", color=color.blue, style=label.style_label_left, yloc=yloc.abovebar)
label.new(bar_index, previousWeekHigh, text="Prev Week High", color=color.purple, style=label.style_label_up, yloc=yloc.abovebar)
label.new(bar_index, previousWeekLow, text="Prev Week Low", color=color.orange, style=label.style_label_down, yloc=yloc.belowbar)
educationalFractalPivot points and levels

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer