HI, I am trying to make a code to get a label to show on a chart whenever a candle is on the VWAP line. Basically if a candles high is above and it's low is below the VWAP I want a label to show on top of the chart that says "VWAP ALERT"
I am new to this and here is what I have so far. It put's the label on the chart but it stays there most of the time whether a candle is over the VWAP or not. It does go away once in a while but comes right back. It seems like it is reacting to the VWAP of the previous candle? I'm not sure but something is triggering it on and off. I am missing something that's for sure.
# current candle straddling Daily VWAP
def cross = (high > VWAP and low < VWAP);
AddLabel (yes, ".........................VWAP ALERT.............................." + if cross then "" else "0", if cross then CreateColor(135, 135, 255) else CreateColor(32, 32, 32));