Get start of previous day on any timeframe
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © haribotagada

//@version=5
indicator("Get start of previous day on any timeframe", overlay = true)

getPreviousDay(int referenceTime = last_bar_time) => 
    dayOfWeekNow = dayofweek(referenceTime) 
    dayOfMonthNow = dayofmonth(referenceTime) 
    monthNow = month(referenceTime) 
    yearNow = year(referenceTime) 

    dayOffset = int(na)
    if syminfo.type == "forex" or syminfo.type == "futures" or syminfo.type == "crypto" or syminfo.type == "spot"
        dayOffset := 1
    else
        // Calculate offset for assets which don't trade 24x7 so we exclude week-ends
        dayOffset := switch dayOfWeekNow
            1 => 2 // Sunday
            2 => 3 // Monday
            3 => 1 // Tuesday
            4 => 1 // Wednesday
            5 => 1 // Thursday
            6 => 1 // Friday
            7 => 1 // Saturday

    referenceDay = timestamp(year=yearNow, month = monthNow, day = dayOfMonthNow, hour=0, minute = 0, second = 0)
    previousDay = referenceDay - ( (24 * 60 * 60 * 1000) * dayOffset)
    previousDay

yesterday = getPreviousDay()

if time >= yesterday and time[1] < yesterday
    label.new(x=bar_index, y=high, style = label.style_label_down, text = 'Yesterday!')