RISK_VIX ---- is Inverted. Stoch/RSI using MetaStock's formula for Stochastics. March 31, 2012
# MetaStock formula compliments of Joe Dupcak
# Line changes color to Red when it has moved at least 10
points above its lowest level over the last 15 periods. Compliments of Richard Houser
# AddLabel compliments of Larry Thompson
# Always calculates off of
VIX data regardless of what security is being charted
declare lower;
plot Scriptlabel = double.nan;
Scriptlabel.SetDefaultColor( CreateColor( 0, 0, 51 ) );
Input Symb = "VIX";
Input length = 21;
Input smooth = 13;
Input RSILength = 14;
input risk_len = 15;
input risk_range = 10.0;
def Vc = Close(Symb);
def LLV = Lowest(Low(Symb), length);
def HHV = Highest(High(Symb), length);
def A = sum(Vc - LLV, smooth);
def B = Sum(HHV - LLV, smooth);
def StochMetaStock = 100 * A / B;
def RSI = reference RSIWilder(length = RSILength, price = Close(Symb));
# 100 - ( ) below is what Inverts the line
def data =100- (StochMetaStock + RSI ) /2;
plot Risk = data;
def risk_LLV = Lowest( data, risk_len );
def risk_color = if data >= ( risk_LLV + risk_range ) and data < 55 then yes else no;
addlabel(yes,"RISK VIX " + Round(Risk,2),color.YELLOW);
Risk.DefineColor( "riskUp", Color.RED );
Risk.DefineColor( "riskFlat", Color.CYAN );
Risk.AssignValueColor( if risk_color then Risk.color( "riskUp" ) else Risk.color( "riskFlat" ) );
plot lowLine = 45;
lowLine.SetPaintingStrategy(PaintingStrategy.LINE);
lowLine.SetDefaultColor(createColor( 255, 100, 100 ));
lowLine.SetLineWeight(1);
lowLine.HideBubble();
plot hiLine = 60;
hiLine.SetPaintingStrategy(PaintingStrategy.LINE);
hiLine.SetDefaultColor(createColor( 102, 102, 255 ));
hiLine.SetLineWeight(1);
hiLine.HideBubble();