Gold Correlation Strategies: Change Indicator and Analysis

During the introduction to our new mini-series investigating the Gold correlations and strategies, we discovered that there appears a significant negative correlation between Gold and the US Dollar Index. Following on from that, I wanted to dive a bit deeper and compare Gold with the US Dollar index on a bar by bar basis. More specifically, take a look at how often the two assets move inversely and whether we can spot any other interesting movements between the two.

To achieve this, we will create a custom indicator on Tradingview. First, we will start with a subjective look at the results from the indicator using the power of the human eyeballs. Then we will create a second indicator to confirm or refute our observations that will provide concrete statistics.

Indicator Scope

The first indicator shall measure the percentage change between the open and close of each bar and compare it to the same percentage change of an alternative asset. In our case, the alternative asset will be the US Dollar Index. Additionally, we shall color the background when the two assets move in the same direction. This should allow us to more easily see when the two assets move together and spot trends in their moment.

Code

On the Charts

Loading up the indicator on “XAUUSD”, you should see something like this:

Synergy Indicator on XAUUSD

 

The yellow bars show the percentage change in the price of gold. The blue bars show the percentage change in the price of the US Dollar Index. If the bar is above zero, it means that the asset closed up. Conversely, if it is below zero, it means the asset closed down. Finally, the grey bars show bars in which the two assets closed in the same direction.

Subjective Analysis

First, we will take a simple look through a selection of time-frames and list our observations. To attempt to have some uniformity between the comparisons, we will look at the last 300 bars for each time-frame. It should be noted that these comparisons are a little flawed as we are only looking at a single time period/market cycle. In an ideal world, we should repeat this analysis for other time periods/market cycles. However, on Tradingiview we can only work with the data that we have and for the lower time-frames that can be as little as a couple of weeks. You can, however, repeat part of these tests on higher time-frames if you so wish to.

Click on the images below to see the the full chart and cycle through:

Observations

  • On all time-frames, the instruments appear to move in opposite directions more frequently than they do in the same direction.
  • The 1-minute time-frame has the most bars where the two instruments move in opposite directions (but we should be skeptical of this for the reasons outlined above)
  • Trends where the two instruments move in the same direction rarely last more than 4 bars.
  • Big moves in the US dollar always result in gold moving in the opposite direction
  • However, the US dollar can move in the same direction as a big move in gold. Albeit, usually a very small move in the same direction.
  • Gold appears to be more volatile than the US Dollar index.

Confirmation

So now we have made some general observations, let’s see if we can back any of them up with some statistics. To do this we are going to edit and extend the indicator to provide the following statistics:

  1. A percentage showing how often the two assets move in the opposite direction over a given lookback period.
  2. Similarly, another percentage showing how often the two assets move in the same direction over the same lookback period.
  3. Count the number of times (occurrences) when the two assets move in the same direction for more than 4 bars.
  4. Count the number of times the US Dollar moves more than x%.
  5. Count the number of times that Gold moved in the same direction of the US Dollar when the US Dollar moved more than x%.

Code

Analysis

Let’s start with the first two observations. Those being that the two instruments close more often than not in opposite directions and that this is most prevalent on the 1-minute chart.

If we load up the new indicator on the 1-minute chart we can see that apart from a short period around the 14th of December, we never dip below 80% for the given 300 bar look back period.

1 Minute Chart
1 Minute Chart : Dip around the 14th

 

In addition to this, at the time of writing the approximate/average percentage that the two instruments move in opposite directions on other timeframes break down as follows:

  • 15M: Hovers around 70%
  • 1H: Also revolves close to approximately 70%
  • 4H: Is less consistent, more frequently ranges from 60-80%
  • 1D: Similar to above, with a larger range from 60-77%
  • 1W: Back to a more consistent 70%

So with this analysis, we can see there is a clear consistent negative correlation between the instruments on all timeframes. Admittedly, this is to be expected given that we had already discovered in the previous post that the two instruments are negatively correlated. However, this might give a fresh perspective by being able to see just how frequently they move inversely. Additionally, we did find that the 1M chart confirms our initial observation but again, remember that pinch of salt.

Trends in which the instruments move in the same direction rarely last more than 4 bars

Moving onto another observation, we will use the same stats indicator to provide insights on how many times we see the two instruments move in sync for more than 4 bars. In this example, we are now interested in the purple line. This line shows us how many times a trend lasted longer than a given input:

Overview of Synergy Stats to count a trend

And the results are as follows (again at the time of writing!):

Very interesting indeed! So overall the observation appears to have some weight. However, it is interesting to note that the occurrences seem to increase as we move through higher timeframes (up to a point) with a big peak on the 4-hour timeframe. Personally, I had expected to higher timeframes to show fewer occurrences as I had assumed there would be more than enough time for traders to adjust to moves in the US Dollar.

Big moves in the US dollar always result in gold moving in the opposite direction

Now we move onto the final observation that we will test. Of course, this is not everything observed in the first section but in fear of dragging this post out too long, we will leave it after this.

For this statistic, we also count the occurrences instead of percentages. After all, it doesn’t mean much if 80% of the time gold is negatively affected by a big move in the US Dollar if that move only occurred 5 times in total.

We are focused on the blue lines of the Indicator. These show us how many times the movement between the open and close in US Dollar was greater than our threshold and of those times, how often Gold moved in the same direction.

During the course of these tests, the input needed to be varied across the time-frames. As such, I tried to use a value on each timeframe that resulted in between 100 and 200 occurrences. In other words, larger moves for that timeframe, but not overly rare so that our stats are meaningless.

The percentages in the chart above indicate the move required in the US Dollar index to be considered a strong move. Also, note that the 1 minute and weekly timeframes were omitted from the test. The reason for this is that it was difficult to get a good number of occurrences. The weekly did not have enough data and the minute data seemed too sensitive to small changes to the input. A 0.001 change saw a swing from 79 to over 350 occurrences!

The results again are quite fascinating and unexpected. The first thing is that the initial observation that Gold always move in the opposite direction to a relatively big move in the US Dollar is untrue! Additionally, the trend appears that gold is less affected by dollar strength, the more we move up the time-frames. However, it should still be noted that on even on the daily, gold moves in sync with US Dollar strength only 24% of the time (137 strong moves to 33 moves in sync)!

Visibility Note

Since the indicator plots both counts and percentages, depending on your settings, the scale can sometimes get a bit wild. This can make the percentage lines hard to read if the counts are very high. In these cases, it is worth to remember that the lines that we are not interested in can be turned off in the style tab like so:

Synergy Style Tab

 

Warning / Further Improvements

The indicator is not perfect. It can provide incorrect results if you are looking at periods where the two data sets are a different length. In other words, data for one asset starts after the other. Take a look at the weekly chart for instance:

Chart showing how the statistics can be inaccurate when data sets are not aligned

The data is actually only valid after we have enough candles on BOTH data sets to cover the lookback period (in our case 300). This is because we need that many candles of data to calculate the value and since the data for the US Dollar starts later than Gold, the candles before this are providing garbage results.

Note: This only affects the calculations that use a lookback period, like the percentage calculations.

To further improve this, we could add a start date to prevent any calculations from happening until we have 300 bars of data on both assets.