OPEN-SOURCE SCRIPT

CC - Asset vs Asset/ETHUSD or /BTCUSD

1 078
Overview:
This indicator measures the correlation between the asset currently displayed on the chart and the ratio of that asset to either ETHUSD or BTCUSD. The correlation is computed using the closing prices of the assets over various lengths, and the final plotted value is an average of these correlations.

Features:

Comparison Asset Selection: The user can select between ETHUSD or BTCUSD as the comparison asset. This determines which cryptocurrency the charted asset will be compared against.

Multiple Length Inputs: The user can define up to five different lengths over which the correlation is computed. This feature allows users to analyze the correlation over different time frames, providing a comprehensive view.

Average Correlation Plot: The indicator doesn't just plot the correlation for a single length; instead, it calculates the correlation for all five lengths and then computes their average. This average correlation is what's plotted on the chart, giving a consolidated measure of the asset's correlation with its ratio to either ETHUSD or BTCUSD.

How It Works:

Fetching Data: The indicator first fetches the closing price of the selected comparison asset, be it ETHUSD or BTCUSD.

Calculating the Ratio: The ratio of the chart asset to the selected comparison asset (either ETHUSD or BTCUSD) is calculated.

Correlation Computation: The correlation between the close prices of the charted asset and the previously calculated ratio is determined over the user-defined lengths.

Averaging: The correlations computed for all five lengths are averaged to get a single value that represents the average correlation.

Plotting: The average correlation is plotted on the chart, with horizontal lines at 1, 0, and -1 to provide a visual reference. A value of 1 indicates perfect positive correlation, -1 indicates perfect negative correlation, and 0 indicates no correlation.

Use Cases:
This indicator is useful for traders and analysts wanting to understand how closely the price movements of an asset follow the movements of its ratio to major cryptocurrencies like ETHUSD or BTCUSD. It helps in assessing the relative strength or weakness of an asset compared to these major cryptocurrencies over multiple time frames.

Important Note: Works on 1D timeframe for most assets. If you get an error try to use the 1D timeframe, or fill all the 5 lengths.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.