Crossover Alerts for Yesterday O/H/L/C , Today Vwap [Zero54]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zero54. Happy Trading!
//@version=5
indicator("Crossover Alerts [Zero54]",overlay=true)

_cross_over_close = ta.crossover(close,close[1])
_cross_under_close = ta.crossunder(close,close[1])
_cross_over_open = ta.crossover(close,open[1])
_cross_under_open = ta.crossunder(close,open[1])
_cross_over_high = ta.crossover(close,high[1])
_cross_under_high = ta.crossunder(close,high[1])
_cross_over_low = ta.crossover(close,low[1])
_cross_under_low = ta.crossunder(close,low[1])
_cross_over_vwap = ta.crossover(close,ta.vwap(hlc3))
_cross_under_vwap = ta.crossunder(close,ta.vwap(hlc3))


[__cross__over__close,__cross__under__close,__cross__over__open,__cross__under__open,__cross__over__high,__cross__under__high,__cross__over__low,__cross__under__low]= request.security("","D",[_cross_over_close,_cross_under_close,_cross_over_open,_cross_under_open,_cross_over_high,_cross_under_high,_cross_over_low,_cross_under_low])
[__cross__over__vwap,__cross__under__vwap]= request.security("","60",[_cross_over_vwap,_cross_under_vwap])

if __cross__over__close and (not __cross__over__close[1])
    alert("Price (" + str.tostring(close) + ") crossed above yesterday's close.", alert.freq_once_per_bar)
if __cross__under__close and (not __cross__under__close[1])
    alert("Price (" + str.tostring(close) + ") crossed below yesterday's close.", alert.freq_once_per_bar)
if __cross__over__open and (not __cross__over__open[1])
    alert("Price (" + str.tostring(close) + ") crossed above yesterday's open.", alert.freq_once_per_bar)
if __cross__under__open and (not __cross__under__open[1])
    alert("Price (" + str.tostring(close) + ") crossed below yesterday's open.", alert.freq_once_per_bar)
if __cross__over__high and (not __cross__over__high[1])
    alert("Price (" + str.tostring(close) + ") crossed above yesterday's high.", alert.freq_once_per_bar)
if __cross__under__high and (not __cross__under__high[1])
    alert("Price (" + str.tostring(close) + ") crossed below yesterday's high.", alert.freq_once_per_bar)
if __cross__over__low and (not __cross__over__low[1])
    alert("Price (" + str.tostring(close) + ") crossed above yesterday's low.", alert.freq_once_per_bar)
if __cross__under__low and (not __cross__under__low[1])
    alert("Price (" + str.tostring(close) + ") crossed below yesterday's low.", alert.freq_once_per_bar)
if __cross__over__low and (not __cross__over__low[1])
    alert("Price (" + str.tostring(close) + ") crossed above yesterday's low.", alert.freq_once_per_bar)
if __cross__under__low and (not __cross__under__low[1])
    alert("Price (" + str.tostring(close) + ") crossed below yesterday's low.", alert.freq_once_per_bar)

if __cross__over__vwap and (not __cross__over__vwap[1])
    alert("Price (" + str.tostring(close) + ") crossed above Vwap.", alert.freq_once_per_bar)
if __cross__under__vwap and (not __cross__under__vwap[1])
    alert("Price (" + str.tostring(close) + ") crossed under Vwap.", alert.freq_once_per_bar)


print_string = "Right click on me and click on 'Add Alert'. \n After you've set the alert you remove the indicator from the chart"
print(txt) =>
    // Create label on the first bar.
    var lbl = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, color.gray, size.large, text.align_left)
    // On next bars, update the label's x and y position, and the text it displays.
    label.set_xy(lbl, bar_index, ta.highest(10)[1])
    label.set_text(lbl, txt)

print(print_string)    