spiritualhealer117

Cryptocurrency Cointegration Matrix (SpiritualHealer117)

This indicator plots a cointegration matrix for the pairings of 100 cryptocurrencies. The matrix is populated with ADF t-stats (from an ADF-test with 1 lag). An ADF-test (Augmented Dickey-Fuller test) tests the null hypothesis that an AR process has a unit root. If rejected, the alternative hypothesis is usually that the AR process is either stationary or trend-stationary. This model extends upon Lejmer's Cointegration Matrix for forex by enabling the indicator to use cryptocurrency pairs and allows for significantly more pairs to be analyzed using the group selection feature. This indicator arose from collaboration with TradingView user CryptoJuju.

This indicator runs an ADF-test on the residuals (spread) of each pairing (i.e. a cointegration test). It tests if there is a unit root in the spread between the two assets of a pairing. If there is a unit root in the spread, it means the spread varies randomly over time, and any mean reversion in the spread is very hard to predict. By contrast, if a unit root does not exist, the spread (distance between the assets) should remain more or less constant over time, or rise/fall in close to the same rate over time. The more negative the number from an ADF-test, the stronger the rejection of the idea that the spread has a unit root. In statistics, there are different levels which correspond with the confidence level of the test. For this indicator, -3.238 equals a confidence level of 90%, -3.589 equals a confidence level of 95% and -4.375 equals a confidence level of 99% that there is not a unit root. So the colors are based on the confidence level of the test statistic (the t-stat, i.e. the number of the pairing in the matrix). So if the number is greater than -3.238 it is green, if it's between -3.238 and -3.589 it's yellow, if it's between -3.589 and -4.375 it's orange, and if its lower than -4.375 it's red.

There are multiple ways to interpret the results. A strong rejection of the presence of a unit root (i.e. a value of -4.375 or below) is not a guarantee that there is no unit root, or that any of the two alternative hypotheses (that the spread is stationary or trend-stationary) are correct. It only means that in 99% of the cases, if the spread is an AR process, the test is right, and there is no unit root in the spread. Therefore, the results of this test is no guarantee that the result proves one of the alternative solutions. Green therefore means that a unit root cannot be ruled out (which can be interpreted as "the two cryptocurrencies probably don't move together over time"), and red means that a unit root is likely not present (which can be interpreted as "the two cryptocurrencies may move together over time").

One possible way to use this indicator is to make sure you don't trade two pairs that move together at the same time. So basically the idea is that if you already have a trade open in one of the currency pairs of the pairing, only enter a trade in the other currency pair of that pairing if the color is green, or you may be doubling your risk. Alternatively, you could implement this indicator into a pairs trading system, such as a simple strategy where you buy the spread between two cryptocurrencies with a red result when the spread's value drops one standard deviation away from its moving average, and conversely sell when it moves up one standard deviation above the moving average. However, this strategy is not guaranteed to work, since historical data does not guarantee the future.

Specific to this indicator, there are 100 different cryptocurrency tickers which are included in the matrix, and the cointegration matrices between all the tickers can be checked by switching asset group 1 and asset group 2 to different asset groups. The ADF test is computed using a specified length, and if there is insufficient data for the length, the test produces a grayed out box.

NOTE: The indicator can take a while to load since it computes the value of 400 ADF tests each time it is run.
Skrip open-source

Dalam semangat TradingView, penulis dari skrip ini telah mempublikasikannya ke sumber-terbuka, maka trader dapat mengerti dan memverifikasinya. Semangat untuk penulis! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.

Inggin menggunakan skrip ini pada chart?