OPEN-SOURCE SCRIPT

BTCUSD Price prediction based on central bank liquidity

Обновлено
In recent months the idea that Bitcoin prices are increasingly linked to liquidity provided by central banks has gained strength. Multiple opinion leaders in the bitcoin space have shared their thoughts to explain why this is happening and why it makes sense. Some of these people I'm talking about are Preston Pysh, Dr. Jeff Ross, Steven McClurg, Lynn Alden among others.

The reality is that the correlation between market liquidity, measured as Assets held by the Federal Reserve, Bank of Japan and European Central bank, and Bitcoin prices is high. This made me wonder whether a regression between "market liquidity" and BTCUSD prices made sense in order to understand where Bitcoin prices are in relation to the liquidity in the market. After several trials I ended up fitting a polynomial regression of degree 5 between Market Liquidity and BTCUSD prices since 2013. This regression resulted in r-squared value of 90.93%. I initially visualized the results in python notebooks but then I thought it would be cool to be able to see them in real-time in tradingview.

That's where this script comes handy...

This script takes the coefficients and intercept from the polynomial regression I built and applies them to the "market_liquidity" index. In addition, it adds upper and lower bound lines to the prediction based on a 95% confidence interval. As you will see, particularly since 2020, the price of bitcoin has rarely been above or below the lines representing the 95% confidence interval. When price has actually crossed these lines it's been in moments where Bitcoin was highly overbought or oversold. Therefore this indicator could be used to understand when it's a good moment to enter or exit the market based on central bank fundamentals.


Here's the detailed step-by-step description of what the script does

1) It defines the coefficients obtained from running the regression betweeen "market liquidity" and BTCUSD. Market liquidity is defined as:

Market liquidity = FRED:WALCL + FX_IDX:JPYUSD*FRED:JPNASSETS + FX:EURUSD*FRED:ECBASSETSW - FRED:RRPONTSYD - FRED:WTREGEN

2) It defines a scale factor. The reason for this is that coefficients from the regression are very small numbers, given the huge numbers of the value of assets held by central banks. Pinescript doesn't support numbers with many decimals and rounds them to 0, so the coefficients had to be scaled up in order to be able to calculate the regression results.

3) It calculates market liquity with the formula defined above. Market liquidity is calculated in US Dollars.

4) It calculates the predicted BTCUSD price based on the coefficients and the market liquidity values.

5) It scales down the values by the same factor used to scale the coefficients up

6) It defines the standard deviation of the "potential_btcusd_price_scaled" and the actual BTCUSD prices.

7) It defines upper and lower bounds to the BTCUSD price prediction using a z-score of 1.96, which is equivalent to 95% confidence interval.

8) Lastly it plots the BTCUSD price prediction (orange) and the upper (red) and lower(green) confidence intervals.

The script can be updated as the correlation of BTCUSD to central bank assets changes (the slope values can be updated).

How to use it:

When actual BTCUSD price (blue line in the chart) crosses over the red line (upper bound) or crosses under the green line (lower bound) it should be taken as a sign that the price of BTCUSD may be overvalued or undervalued based on the value of assets held by major central banks.
Информация о релизе
As per multiple requests I've added CNCBBS*FX_IDC:CNYUSD to the total liquidity calculation. Consequently I've had to run the regression again using the new liquidity figure. The new R2 is 90.48% down slightly from the previous 90.86%. The script has updated slope values, intercept and stdev to calculate the confidence lines. Thank you to the community for providing info on where to obtain China Central Bank balance sheet data to run the calculations.
forecastingFundamental Analysis

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?

Отказ от ответственности