VIX MTF label

grapetux

Member
Hey there. Im attempting to display a label on my main 2min price chart showing whether a 5min vix chart is bullish/bearish via a 20ema/50ema crossover.

I'm running into trouble including 'VIX' into the mtf label. How do I reference VIX for the moving average?

input Period = aggregationPeriod.five_minute;
input AvgType = averageType.exponential;
input Length = 20;
input priceclose = close; ## def vix = close("VIX"); <-- not getting this to work

plot AVG = MovingAverage(AvgType, close(period = Period), Length);

thanks for the help, cheers
 
Solution
Hey there. Im attempting to display a label on my main 2min price chart showing whether a 5min vix chart is bullish/bearish via a 20ema/50ema crossover.

I'm running into trouble including 'VIX' into the mtf label. How do I reference VIX for the moving average?

input Period = aggregationPeriod.five_minute;
input AvgType = averageType.exponential;
input Length = 20;
input priceclose = close; ## def vix = close("VIX"); <-- not getting this to work

plot AVG = MovingAverage(AvgType, close(period = Period), Length);

thanks for the help, cheers

The VIX has gaps in data that often do not match the data on your chart you are displaying the label. To fix this the VIX data refers to the prior value of it when there is a gap. See AVG...
Hey there. Im attempting to display a label on my main 2min price chart showing whether a 5min vix chart is bullish/bearish via a 20ema/50ema crossover.

I'm running into trouble including 'VIX' into the mtf label. How do I reference VIX for the moving average?

input Period = aggregationPeriod.five_minute;
input AvgType = averageType.exponential;
input Length = 20;
input priceclose = close; ## def vix = close("VIX"); <-- not getting this to work

plot AVG = MovingAverage(AvgType, close(period = Period), Length);

thanks for the help, cheers

The VIX has gaps in data that often do not match the data on your chart you are displaying the label. To fix this the VIX data refers to the prior value of it when there is a gap. See AVG isnan() fix.

Also, since you made priceclose an input, you have to use fundamentaltype price format there. Then in the moving average, the fundamental function format to provide the symbol and period input values.

Capture.jpg
Ruby:
input symbol  = "VIX";
input Period  = AggregationPeriod.FIVE_MIN;
input AvgType = AverageType.EXPONENTIAL;
input Length  = 20;
input priceclose = FundamentalType.CLOSE; ## def vix = close("VIX"); <-- not getting this to work

def AVG = if IsNaN(MovingAverage(AvgType, Fundamental(priceclose, symbol, period = Period), Length))
          then AVG[1]
          else MovingAverage(AvgType, Fundamental(priceclose, symbol, period = Period), Length);

AddLabel(1, "VIX " + (Period / 60000) + "m " +length +"MA: " + AsText(AVG), Color.WHITE);
 
Solution
The VIX has gaps in data that often do not match the data on your chart you are displaying the label. To fix this the VIX data refers to the prior value of it when there is a gap. See AVG isnan() fix.

Also, since you made priceclose an input, you have to use fundamentaltype price format there. Then in the moving average, the fundamental function format to provide the symbol and period input values.
The VIX has gaps in data that often do not match the data on your chart you are displaying the label. To fix this the VIX data refers to the prior value of it when there is a gap. See AVG isnan() fix.

Also, since you made priceclose an input, you have to use fundamentaltype price format there. Then in the moving average, the fundamental function format to provide the symbol and period input values.
Hey SleepyZ, thanks very much. This was wayy above my abilities. Appreciate learning something new
Does using priceclose vs. using regular close as you pointed out, make any difference in this scenario?
thanks
 
Hey SleepyZ, thanks very much. This was wayy above my abilities. Appreciate learning something new
Does using priceclose vs. using regular close as you pointed out, make any difference in this scenario?
thanks

It is the use of theninput for close that causes the additional work. If you know that you are going to just use close, then the following works. But if you want to change close to some other price then you have to do it inside the code rather than at the input screen.
 
That defined the part of the label as 5 minutes. That way if you change the period, it will change the label's period without you having only to change the input. Same issue as with close, input vs inside code.
Thanks again.. Here's the final code i put together to show sentiment on vix..

input symbol = "VIX";
input Periodv = AggregationPeriod.FIVE_MIN;
input AvgTypev = AverageType.EXPONENTIAL;
input Lengthv = 20;
input Lengthv1 = 50;
input priceclose = FundamentalType.CLOSE;
def vix = close("vix");

def v20 = if IsNaN(MovingAverage(AvgTypev, Fundamental(priceclose, symbol, period = Periodv), Lengthv))
then v20[1]
else MovingAverage(AvgTypev, Fundamental(priceclose, symbol, period = Periodv), Lengthv);

def v50 = if IsNaN(MovingAverage(AvgTypev, Fundamental(priceclose, symbol, period = Periodv), Lengthv))
then v50[1]
else MovingAverage(AvgTypev, Fundamental(priceclose, symbol, period = Periodv), Lengthv1);

addlabel(yes, if v20>v50 then " VIX 5min:Bearish " else if v50>v20 then " VIX 5min:Bullish " else if v20>v50 and vix<v20 or v20<v50 and vix>v20 then " VIXCHOP " else " VIXCHOP " , if v20>v50 then color.light_red else if v50>v20 then color.light_green else if v20>v50 and vix<v20 or v20<v50 and vix>v20 then color.orange else color.orange);


thanks for all your help
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
513 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top