OTFHigh'nLows
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RomankoJr

//@version=5


// Daily High Prices
indicator("OTFHigh'nLows", overlay=true)
[mh, ml] = request.security(syminfo.tickerid, 'M', [high[1], low[1]], lookahead=barmerge.lookahead_on)

[wh, wl] = request.security(syminfo.tickerid, 'W', [high[1], low[1]], lookahead=barmerge.lookahead_on  )


[dh, dl] = request.security(syminfo.tickerid, 'D', [high[1], low[1]], lookahead=barmerge.lookahead_on)


[h4h, h4l] = request.security(syminfo.tickerid, '240', [high[1], low[1]] )


[h1h, h1l] = request.security(syminfo.tickerid, '60', [high[1], low[1]])


[m30h, m30l] = request.security(syminfo.tickerid, '30', [high[1], low[1]])

isTodayM = false
isTodayW = false
isTodayD = false

if year(timenow) == year(time) and month(timenow) == month(time)
    isTodayM := true
else
    isTodayM := false
    
if year(timenow) == year(time) and month(timenow) == month(time) and weekofyear(timenow) == weekofyear(time)
    isTodayW := true
else
    isTodayW := false

if year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time)
    isTodayD := true
else
    isTodayD := false

if barstate.isrealtime
    label.new(bar_index, mh, "Prev. Month\nHigh = " + str.tostring(mh, format.mintick) + "\n🠇", style = label.style_none, textcolor = color.black, size = size.large)
    label.new(bar_index, ml, "Prev. Month\nLow = " + str.tostring(ml, format.mintick) + "\n🠇", style = label.style_none, textcolor = color.black, size = size.large)

if barstate.isrealtime
    label.new(bar_index, wh, "Prev. Week\nHigh = " + str.tostring(dh, format.mintick) + "\n🠇", style = label.style_none, textcolor = color.black, size = size.normal)
    label.new(bar_index, wl, "Prev. Week\nLow = " + str.tostring(dl, format.mintick) + "\n🠇", style = label.style_none, textcolor = color.black, size = size.normal)

if barstate.isrealtime
    label.new(bar_index, dh, "Prev. Day\nHigh = " + str.tostring(dh, format.mintick) + "\n🠇", style = label.style_none, textcolor = color.black, size = size.normal)
    label.new(bar_index, dl, "Prev. Day\nLow = " + str.tostring(dl, format.mintick) + "\n🠇", style = label.style_none, textcolor = color.black, size = size.normal)

plot(mh, title="Month H", color= isTodayM[1] ? color.blue : #00000000)
plot(ml, title="Month L", color= isTodayM[1] ? color.blue : #00000000)

plot(wh, title="Week H", color= isTodayW[1] ? color.blue : #00000000)
plot(wl, title="Week L", color= isTodayW[1] ? color.blue : #00000000)

plot(dh, title="Day H", color= isTodayD[1] ? color.blue : #00000000)
plot(dl, title="Day L", color= isTodayD[1] ? color.blue : #00000000)