WEEKLY AND TWO DAY HIGH LOW
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © 487551

//@version=5
indicator("TWO DAY AND WEEKLY HIGH LOW", shorttitle="TWO DAY AND WEEKLY HIGH LOW", overlay=true)

// Calculate the high and low of the two most recent candles
high1 = request.security(syminfo.tickerid, "W", high[1])
low1 = request.security(syminfo.tickerid, "W", low[1])
high2 = request.security(syminfo.tickerid, "D", high[2])
low2 = request.security(syminfo.tickerid, "D", low[2])

// Plot lines to connect the high and low of the two most recent candles
plot(high1, title="WEEK High", color=color.green, linewidth=2, style=plot.style_line)
plot(low1, title="WEEK Low", color=color.red, linewidth=2, style=plot.style_line)

plot(high2, title="2 DAY High", color=color.green, linewidth=2, style=plot.style_line)
plot(low2, title="2 DAY Low", color=color.red, linewidth=2, style=plot.style_line)
