• Get $40 off VIP by signing up for a free account! Sign Up



New member
This may be considered off topic, since it isn't about ThinkScript. I don't know where else to ask this question.

I've written a program that uses candle data to calculate the MACD for a given symbol over a specified period of time. When I run the program for /ES and compare the results to the MACD-2-line study, my results are within 0.001 of being the same as those at ThinkOrSwim. However, when I run the program for VIX, my results differ from those at ThinkOrSwim by as much as 0.05 to 0.20.

I'm using the exact same formulae to calculate the MACDs for /ES and VIX, but, getting very different results. Can anyone suggest why my VIX MACDs don't match with those at ThinOrSwim? I'd really appreciate anyone's help with this.
@hyperbole We have so many very very smart people on this forum, one of them might chime in or someone else may have run into a similar problem and be able to answer your question. However, if you do not get an answer and you end up going to TOS Support, could you come back and tell us their answer? I am interested.
@rad14733, I had considered that possibility, but since the VIX values are all between 0 and 100, and it's MACDs are -2.00 to 2.00, and the calculations are done with 64-bit floating point numbers, I don't think I'm experiencing rounding issues. But, I'll look into that some more to absolutely rule it out.
@hyperbole The issue may be due to the fact that VIX is not directly tradable whereas /ES is a tradable instrument... Therefore VIX is only an index based on volatility algorithms rather than actual time-based trade data and as such could be easily skewed...
I don't understand that. Why would tradable vs non-tradable make a difference in the way the MACDs are calculated?

I said it "may" be due . . . . Call Thinkorswim Tech Support if you want a more concrete answer...

The VIX Index is calculated between 2:15 a.m. CT and 8:15 a.m. CT and between 8:30 a.m. CT and 3:15 p.m. CT. Only SPX options with more than 23 days and less than 37 days to the Friday SPX expiration are used to calculate the VIX Index.

/ES is traded: Sunday - Friday 5:00p.m. - 4:00p.m. CT with a trading halt from 3:15p.m. - 3:30p.m. CT; Daily Maintenance period Monday - Thursday 4:00p.m. - 5:00p.m.
I finally have an answer for this question. It's actually two answers, and neither one is very satisfying. I wanted to update this thread in case someone in the future ran into a similar problem.

The first answer is: My colleague who noticed the discrepancy between our calculations for MACD using VIX candle data ran our program for a single day. On ThinkOrSwim, thinkScript calculations are calculated from an effectively infinite back store of data, so any time the MACD calculations take to "settle in" are not apparent when they display the data. My program, on the other hand, starts calculating MACDs from one day ahead of a given day, for example, if you asked to see MACDs for 2021-05-03 ... 2021-05-14, the program will prime its MACD calculations by starting with 2021-04-30. The MACDs, nor candle data for 2021-04-30 will not be used in any other part of the program, they are simply used to get the MACD calculations going. My colleague was using the program to calculate MACDs for a single day, which I believe was not enough time to let the MACDs stabilize.

Second: I contacted ThinkOrSwim support and they suggested resetting the chart to Factory Defaults. We tried that and the MACD data we were seeing matched the calculations from my program to within +/-0.05. Even though we had previously checked the parameters we were using in the MACD calculations at ThinkOrSwim and found no differences from the MACD parameters used in my program, resetting to Factory Defaults on ThinkOrSwim seems to have made a difference in how thinkScript was performing the calculations.

As I said, I'm not very satisfied with this result, but, I hope it may be helpful to someone else in the future.

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
355 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.