How to build a chart that displays the ratio of the Dow Jones Industrial average to the price of gold using thinkScript in the thinkorswim platform by TD Ameritrade
When asked to describe a widespread problem and then offer a solution I thought they meant for something like global warming. But alas, it was to solve a problem related to thinkorswim® using thinkScript®, the do-almost-anything-we-didn’t-think-of tool.
For my first trick, I want to show you how to build a chart that displays the ratio of the Dow Jones Industrial average to the price of gold. Despite the name, the “Dow-to-Gold Ratio” is used by many traders to tell how overpriced the S&P 500 (SPX) might be.
Referring to Figure 1 below, you can see historically as the SPX hit new highs, gold was also at highs, and the ratio remained relatively low. But at the time of writing, as SPX continues to rise, gold is going down. So SPX is becoming expensive valued in gold as well as U.S. dollars.
The Dow-to-gold ratio has been used to analyze everything from stock-market moves to predicting upcoming interest-rate decisions. We aren’t going to delve into Dow-to-gold theories, but rather describe how to see this ratio on thinkorswim. The problem we face is you can’t enter ratios in the symbol entry box on thinkorswim. So we need to think outside the (symbol entry) box to solve this one.
Starting on the thinkorswim Charts tab, bring up a one-year daily chart of the S&P 500 index by entering SPX in the symbol box. We’re going to build a study for a lower sub-graph of the chart in which the displayed data will be independent of the charted symbol—meaning, you can change the symbol without changing the new study. Once you see an SPX chart, fire up the thinkScript Editor by following the sidebar “Scripting from the Charts.” Then enter the following script:
After you’ve entered the above code, press Apply and OK and you’ll see a chart similar to Figure 2, with the Dow-to-gold indicator at the bottom.
Now let’s break down the code line by line to help you figure out how you got there.
Congrats, you have your own Dow-to-gold ratio chart. And since you solved this in a smart way, you now create any ratio chart you desire simply by editing the symbols in lines 3 and 4. We may not have solved global warming today, but we did make one small step for a legion of traders!