Show the Moving Average of another Security

Skyfly93

New member
Can anyone build a study that display the moving average of a secondary security onto the primary chart as a lower study?

For example, is it possible to see the 10-day moving average of VIX (secondary security) shown on the ES chart lower study? Ideally, would like to make the secondary security an input.
 
Hey @Skyfly93 - Can you try this and confirm it does what you need?

Code:
input price = close;
input length = 9;
input displace = 0;
input ticker = "VIX";

declare lower;

plot SMA = Average(close(ticker)[-displace], length);

SMA.SetDefaultColor(GetColor(1));

addlabel(1,"Moving Average: " + ticker);
 

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

@Skyfly93 Could you please post a screenshot? Here are 2 shots from my system where you can see on the daily and hourly the VIX mainchart values match the lower chart values.

RsFiGa3.jpg


snyN8PN.jpg
 
Can't seem to attach photos into here directly so posted a link below.

As you can see, the both the VIX and /VX MA lag the /ES chart by a few bars.

Interestingly, plotting /VX upper and lower eliminates the issue as does plotting /ES against /ES. I can kinda see why /ES vs VIX doesnt work correctly because of the different trading hours, but I can't immediately see why you see the lag on /ES vs /VX. I'll keep looking.

Edit: Even more interesting, there is a lag with /ES main and /VX lower, but no lag with /VX main and /ES lower. I am confused.
 
Interestingly, plotting /VX upper and lower eliminates the issue as does plotting /ES against /ES. I can kinda see why /ES vs VIX doesnt work correctly because of the different trading hours, but I can't immediately see why you see the lag on /ES vs /VX. I'll keep looking.

Edit: Even more interesting, there is a lag with /ES main and /VX lower, but no lag with /VX main and /ES lower. I am confused.
I would be very confused as well.

Yes I expect VIX not to lag but just not plot during globex hours, but there's still a lag on VIX on the daily looking at ES, which shouldn't be the case.

Not sure what's causing this though since the code you wrote is fairly simple and straightforward.
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
505 Online
Create Post

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