INVITE-ONLY SCRIPT
Updated

Adaptive Power Law Fitting by Dr. G. Santostasi

5 965
This script is based on the work of G. Santostasi, the creator of the BTC Power Model by the creator himself.

The BTC Power Law Model creates a linear fit by assuming a power law relationship between the Price and time (measured in days from the Genesis) block and therefore uses the log of the price and the log of time (that is rarely used in financial analysis) to perform the regression calculation. It turns out that this unusual but simple approach represents a surprisingly good long-term approximation of the BTC price (with an R^2=0.95).

While Dr. Santostasi is the creator of the model other Pinescripts exist using the methodology borrowed from his work. Dr. Santostasi inspected the code of these scripts and they are incorrect or they use a static formula for the fitting instead of doing the regression in real time based on current data. This is why this current script is called "adaptive".

It uses current data, cleans the data of large outliers using several statistical methods and creates an online robust fitting in the log-log space. It is also adaptive because instead of being only valid on a daily bar time frame it can be used at all time frames (even if daily is ideal).
The other existent scripts cannot be used in this way because they use a static method designed only for the daily time frame.

Another innovation of the current script is to identify deviation levels from the trend that are based on sound statistical methods. A log-normal distribution of the residuals is assumed (based on the actual distribution of the BTC deviations). These distributions then it is then used to determine possible resistance and support levels at the relevant scale chosen by the user.

The script also contains other relevant information like previous and the next halvings.

Furthermore, the script projects the prediction of the model to the future (again missing from most existing PL scripts) several bars in the future selected as a parameter by the user.
Release Notes
This script is based on the work of G. Santostasi, the creator of the BTC Power Model by the creator himself.

The BTC Power Law Model creates a linear fit by assuming a power law relationship between the Price and time (measured in days from the Genesis) block and therefore uses the log of the price and the log of time (that is rarely used in financial analysis) to perform the regression calculation. It turns out that this unusual but simple approach represents a surprisingly good long-term approximation of the BTC price (with an R^2=0.95).

While Dr. Santostasi is the creator of the model other Pinescripts exist using the methodology borrowed from his work. Dr. Santostasi inspected the code of these scripts and they are incorrect or they use a static formula for the fitting instead of doing the regression in real time based on current data. This is why this current script is called "adaptive".

It uses current data, cleans the data of large outliers using several statistical methods and creates an online robust fitting in the log-log space. It is also adaptive because instead of being only valid on a daily bar time frame it can be used at all time frames (even if daily is ideal).
The other existent scripts cannot be used in this way because they use a static method designed only for the daily time frame.

Another innovation of the current script is to identify deviation levels from the trend that are based on sound statistical methods. A log-normal distribution of the residuals is assumed (based on the actual distribution of the BTC deviations). These distributions then it is then used to determine possible resistance and support levels at the relevant scale chosen by the user.

The script also contains other relevant information like previous and the next halvings.

Furthermore, the script projects the prediction of the model to the future (again missing from most existing PL scripts) several bars in the future selected as a parameter by the user.
Release Notes
Added the projection for the full model.
Release Notes
Updated the location and value of the cycle peak label. Now it displays correctly the location and value of the Cycle peak.

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.