input LOOKUP_RSI = "VIX";
def c = if IsNaN( close(symbol = LOOKUP_RSI)) then c[1] else close(symbol = LOOKUP_RSI);
def LOOKUPRSI = RSI(price = c, length = 5);
def RSI = LOOKUPRSI;
input overBought = 80;
input overSold = 20;
input lineweight = 2;
input arrows = no;
def rth = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0;
plot up = RSI crosses above overBought;
up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
up.SetHiding(!arrows);
def uph = if up[-2] then Highest(high[-2], 3) else uph[1];
def upl = if up[-2] then Lowest(low[-2], 3) else upl[1];
plot xuph = uph;
xuph.SetPaintingStrategy(PaintingStrategy.DASHES);
xuph.AssignValueColor(if up or up[-1] or up[-2] then GlobalColor("UP") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xuph.SetLineWeight(lineweight);
plot xupl = upl;
xupl.SetPaintingStrategy(PaintingStrategy.DASHES);
xupl.AssignValueColor(if up or up[-1] or up[-2] then GlobalColor("UP") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xupl.SetLineWeight(lineweight);
plot dn = RSI crosses below overSold;
dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
dn.SetHiding(!arrows);
def dnh = if dn[-2] then Highest(high[-2], 3) else dnh[1];
def dnl = if dn[-2] then Lowest(low[-2], 3) else dnl[1];
plot xdnh = dnh;
xdnh.SetPaintingStrategy(PaintingStrategy.DASHES);
xdnh.AssignValueColor(if dn or dn[-1] or dn[-2] then GlobalColor("DN") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xdnh.SetLineWeight(lineweight);
plot xdnl = dnl;
xdnl.SetPaintingStrategy(PaintingStrategy.DASHES);
xdnl.AssignValueColor(if dn or dn[-1] or dn[-2] then GlobalColor("DN") else if rth then GlobalColor("RTH") else GlobalColor("EXT"));
xdnl.SetLineWeight(lineweight);
DefineGlobalColor("UP", Color.GREEN);
DefineGlobalColor("DN", Color.RED);
DefineGlobalColor("RTH", Color.BLACK);
DefineGlobalColor("EXT", Color.DARK_GRAY);
#