Need help with label code:
My goal is to put a VIX moving average label on a 2 minute SPY chart.
I use a 20 minute EMA on a 2 minute VIX chart that changes to green when AvgExp > AvgExp[1] and red when it’s not.
To save space on my travel computer, I want to convert the EMA color change info on the VIX chart into a label that I can put on my 2 minute SPY chart. Theoretically, this way I can see if the VIX is rising or falling without looking at an actual VIX chart.
However, I have not been able to get the code to work properly.
Any assistance would be greatly appreciated.
——————
# VIX_Label
declare upper;
def aggregationPeriod = AggregationPeriod.TWO_Min;
input VIX = “VIX”;
input price = close;
input length = 20;
input displace = 0;
input showLabel = yes;
plot AvgExp = ExpAverage(price[-displace], length);
AvgExp.AssignValueColor(if AvgExp > AvgExp[1] then Color.GREEN else Color.RED);
AvgExp.SetHiding(1);
AddLabel(showLabel, “VIX 20ema", if AvgExp > AvgExp[1] then Color.GREEN else Color.RED);
My goal is to put a VIX moving average label on a 2 minute SPY chart.
I use a 20 minute EMA on a 2 minute VIX chart that changes to green when AvgExp > AvgExp[1] and red when it’s not.
To save space on my travel computer, I want to convert the EMA color change info on the VIX chart into a label that I can put on my 2 minute SPY chart. Theoretically, this way I can see if the VIX is rising or falling without looking at an actual VIX chart.
However, I have not been able to get the code to work properly.
Any assistance would be greatly appreciated.
——————
# VIX_Label
declare upper;
def aggregationPeriod = AggregationPeriod.TWO_Min;
input VIX = “VIX”;
input price = close;
input length = 20;
input displace = 0;
input showLabel = yes;
plot AvgExp = ExpAverage(price[-displace], length);
AvgExp.AssignValueColor(if AvgExp > AvgExp[1] then Color.GREEN else Color.RED);
AvgExp.SetHiding(1);
AddLabel(showLabel, “VIX 20ema", if AvgExp > AvgExp[1] then Color.GREEN else Color.RED);