//@version=4 study(title="VWAP Super ", shorttitle="vwapB/S", resolution="", overlay=true) vwapValue = vwap(hlc3) // 1. Calculating vwapValue's rate of change offset_num = input(defval=0, title="???", minval=-24, maxval=24, type=input.integer, step=1) change_rate_threshold = input(defval=0.4, title="?????", minval=0.02, maxval=2, type=input.float, step=0.02, tooltip="?????????,VWAP?????????????????,?????????") change_rate = (vwapValue - nz(vwapValue[1], 0)) / ((ema(source=close, length=144) + ema(source=close, length=169)) / 2) * 100 // 2. Controlling Line's color based on the average change rate against Vegas var color_flag = 1 // 3. Calculating average change rate in the past k-lines bull_flag = (color_flag == 0 and change_rate >= change_rate_threshold) bear_flag = (color_flag == 1 and change_rate <= -change_rate_threshold) plotshape(bull_flag ? 1 : na, style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, offset=0) plotshape(bear_flag ? 1 : na, style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small, offset=0) if color_flag == 1 and change_rate > -change_rate_threshold color_flag := 1 if bear_flag color_flag := 0 if bull_flag color_flag := 1 if color_flag == 0 and change_rate < change_rate_threshold color_flag := 0 plot(vwapValue, title="VWAP", color = color_flag == 1 ? color.green : color.red, offset=0, linewidth=2) alertcondition(bull_flag, title="VWAP Bull Alert", message="??[??]??(Super VWAP) - {{exchange}} : {{ticker}} ?{{interval}}??VWAP????!\n????:{{close}}\n????:{{timenow}}") alertcondition(bear_flag, title="VWAP Bear Alert", message="??[??]??(Super VWAP) - {{exchange}} : {{ticker}} ?{{interval}}??VWAP????!\n????:{{close}}\n????:{{timenow}}")