Compare UVXY to its VIX futures basket
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mot_redat

//@version=5
indicator("Compare UVXY to its VIX futures basket", "CMP-UVXY-FUT")
refcolor = input.color(color.white, "Reference value")
actcolorup = input.color(color.green, "Actual value (up)")
actcolordown = input.color(color.red, "Actual value (down)")
uvxy = request.security("UVXY", "", close)
fut = request.security("(2.2*CBOE:VX1!+8.8*CBOE:VX2!)/11", "", close)
diffUVXY = math.abs(uvxy[1] - uvxy[0]) / uvxy[1]
diffFut = math.abs(fut[1]-fut[0]) / fut[1]
actUp = (fut[0] - fut[1]) > 0
hline(1.5, title = "reference", color = refcolor, linestyle = hline.style_dashed)
plot(diffUVXY/diffFut, color = actUp ? actcolorup : actcolordown, linewidth = 2)
