- Platform
-
- Thinkorswim
Converted for discord chatroom request. Original TradingView indicator: https://www.tradingview.com/script/dOvHSQxB-VIX-INDICATOR/
There seems to be a difference between ToS and TradingView data. Although code matches, it won't display the same.
There seems to be a difference between ToS and TradingView data. Although code matches, it won't display the same.
Code:
# Converted for b4indicators.com
# barbaros
declare lower;
input symb1 = "VIXMO";
input symb2 = "VIX3M";
input symb3 = "VVIX";
input symb4 = "VXST";
def MOD1 = close(symbol = symb1);
def MOD2 = close(symbol = symb2);
def MOD3 = close(symbol = symb3);
def MOD4 = close(symbol = symb4);
def C0 = MOD1 * MOD2 * MOD3 * MOD4;
input CLOSE0 = 21; # HINT: EMA Close
def KC0 = expAverage(C0, CLOSE0);
plot LongEMA_close = KC0;
LongEMA_close.SetPaintingStrategy(PaintingStrategy.LINE);
LongEMA_close.SetLineWeight(2);
LongEMA_close.SetDefaultColor(color.orange);
input CLOSE1 = 8; # HINT: shortEMA Close
def KC1 = expAverage(C0, CLOSE1);
plot shortEMA_close = KC1;
shortEMA_close.SetPaintingStrategy(PaintingStrategy.LINE);
shortEMA_close.SetLineWeight(2);
shortEMA_close.SetDefaultColor(color.blue);
input EnableBackgroundColor = yes;
AssignBackgroundColor(if EnableBackgroundColor then
if C0 < KC1 then color.orange else color.black
else Color.CURRENT
);
plot C0_Line = C0;
LongEMA_close.SetPaintingStrategy(PaintingStrategy.LINE);
LongEMA_close.SetLineWeight(3);
LongEMA_close.SetDefaultColor(color.cyan);
plot EMA_Short = KC1;
EMA_Short.SetPaintingStrategy(PaintingStrategy.LINE);
EMA_Short.SetLineWeight(3);
EMA_Short.AssignValueColor(if KC1>=KC0 then color.lime else color.red);
plot EMA_Long = KC0;
EMA_Long.SetPaintingStrategy(PaintingStrategy.LINE);
EMA_Long.SetLineWeight(3);
EMA_Long.AssignValueColor(if KC1>=KC0 then color.lime else color.red);
AddCloud(EMA_Short, EMA_Long, color.gray, color.gray);