Support & Resistance PRO
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlexShech

//@version=5
indicator("Support & Resistance PRO", overlay=true)

inpPeriod = input.int(defval = 30, title='Look Back Period')
inpRF = input.timeframe('D', "Medium Time Frame")
inpRF2 = input.timeframe('W', "Macro Time Frame")

inpShow1 = input.bool(defval=true,title='Show Medium Target')
inpShow2 = input.bool(defval=true,title='Show Macro Target')

PDH15 = request.security(syminfo.tickerid, inpRF, ta.highest(close, inpPeriod))
PDL15 = request.security(syminfo.tickerid, inpRF, ta.lowest(close, inpPeriod))
PDH15w = request.security(syminfo.tickerid, inpRF, ta.highest(high, inpPeriod))
PDL15w = request.security(syminfo.tickerid, inpRF, ta.lowest(low, inpPeriod))
PDH60 = request.security(syminfo.tickerid, inpRF2, ta.highest(close, inpPeriod))
PDL60 = request.security(syminfo.tickerid, inpRF2, ta.lowest(close, inpPeriod))
PDH60w = request.security(syminfo.tickerid, inpRF2, ta.highest(high, inpPeriod))
PDL60w = request.security(syminfo.tickerid, inpRF2, ta.lowest(low, inpPeriod))

var line pdh = na
var line pdl = na
var line pdhw = na
var line pdlw = na
var line pdh4 = na
var line pdl4 = na
var line pdh4w = na
var line pdl4w = na

if barstate.islast and inpShow1 == true
    pdh := line.new(bar_index-1, PDH15, bar_index, PDH15, extend=extend.both, color=color.rgb(65, 255, 71))
    pdl := line.new(bar_index-1, PDL15, bar_index, PDL15, extend=extend.both, color=color.rgb(251, 65, 65))
    pdhw := line.new(bar_index-1, PDH15w, bar_index, PDH15w, extend=extend.both, color=color.rgb(100, 100, 100, 62))
    pdlw := line.new(bar_index-1, PDL15w, bar_index, PDL15w, extend=extend.both, color=color.rgb(100, 100, 100, 59))
    linefill.new(pdh,pdhw,color.rgb(73, 73, 73, 77))
    linefill.new(pdl,pdlw,color.rgb(73, 73, 73, 75))

if barstate.islast and inpShow2 == true
    pdh4 := line.new(bar_index-1, PDH60, bar_index, PDH60, extend=extend.both, color=color.rgb(255, 255, 255))
    pdl4 := line.new(bar_index-1, PDL60, bar_index, PDL60, extend=extend.both, color=color.rgb(255, 255, 255))
    pdh4w := line.new(bar_index-1, PDH60w, bar_index, PDH60w, extend=extend.both, color=color.rgb(127, 127, 127, 47))
    pdl4w := line.new(bar_index-1, PDL60w, bar_index, PDL60w, extend=extend.both, color=color.rgb(127, 127, 127, 47))
    linefill.new(pdh4,pdh4w,color.rgb(0, 13, 253, 90))
    linefill.new(pdl4,pdl4w,color.rgb(0, 13, 253, 90))

line.delete(pdh[1])
line.delete(pdl[1])
line.delete(pdh4[1])
line.delete(pdl4[1])
line.delete(pdh4w[1])
line.delete(pdl4w[1])
// lastBig = request.security(syminfo.tickerid, inpBig, close[barstate.isrealtime ? 1 : 0])    //previous close
