Update:
* Fix statistical calculation errors for lowerthan side of the significance test, now the 2sided test is accurate (checked against another programming language implementation).
* Simplified statistical test and hence confidence interval: now the test is not reversed depending on positive or negative correlation, so the values can go below 0.5 when there is negative correlation. This allows for a more intuitive reading, and avoids some mixups when there is a fast change in correlation.
* Updated instructions, please read inside the script, instructions too long to be posted here. Essentially, the color changed, and how to read the indicator is better described. Excerpt of the most important part:
Usage: When positive, the two symbols tend to move together. When negative, the symbols move in opposite directions.
Since the raw DCC value (of one bar) is binary, it will always go towards 1 or -1 at each new bar, because technically there is always a correlation or anticorrelation for each bar, unless one or both markets are closed (in which case, the value is filled with 0). Nevertheless, if there is no correlation, the value will hover alternatively between -1 and 1, without a clear trend. There are two solutions for this issue: visualize historical trends, and significance testing, both of which are implemented here.
The first approach, to visualize historical trends, is by using an EMA or SMA that is applied to smooth out transitions: SMA smoothes over the selected length period but adds lag, whereas EMA smoothes amplitude without any additional lag. Hence, to know if the correlation is true or not, try to look at the amplitude and the number of consecutive days the correlation is maintained (both quantities are related), because when the correlation is spurious, it will tend to switch more or less alternatively between 1 and -1 and hence will hover around 0, whereas if the correlation is true, it will get further away from 0 and closer to 1 or -1.
Intuitively, the value of the averaged DCC (height of the curve) represents the probability of a correlation (if positive) or anticorrelation (if negative) of any bar during the selected period. For example, if the length is set to 14, and the value is 0.5, then it means that during the 14 last bars, you would have been right about 75% of the time if you had bet any bar during this period would been in positive correlation between these two symbols.
Hence, the averaged DCC allows to account for the temporality, to know not just the correlation of current bar but of a number of past bars. However, the downside is that as with any moving average indicator, the averaged correlation is lagging by about length/2, as John F. Ehlers indicated.
Consequently, to overcome this time lag of the average DCC, the raw DCC is also used by coloring the area to know the current candle's correlation, regardless of past data's correlation: green is a positive correlation (1), yellow is negative. The coloring can allow to know a trend reversal early on, but it's noisy.
Intuitively, the area's color represent the current, instantaneous binary correlation, which can be in the same direction as the average DCC correlation and hence increasing it, or in opposite direction and hence reducing it. The raw DCC (area's color) can hence be very useful to visualize the start or end of trends, that will get reflected later on the averaged DCC after the time lag period has passed.