In our long-term strategy, we dig deeper into the key factors affecting Bitcoin priceBy accurately calculating the correlation of these factors with the price of Bitcoin, we found that they are closely linked to the value of BitcoinIn order to more effectively predict the reasonable price of Bitcoin, we built a prediction model and adjusted the investment strategy accordingly.Practice has proved that the prediction results of this model are in good agreement with the actual value, which fully proves its reliability in predicting price fluctuations.

As Greenspan said: “When the future is difficult to predict and the prospects are unclear, people often choose to stagnate, avoid risks, or even give up their original plans.“Bitcoin predictions are fraught with challenges, but we’ve taken the first steps in exploration

Directory:

Usage Guide

Step 1: Identify the factors that have the greatest impact on Bitcoin price

Step 2: Establish a Bitcoin price prediction model

Step 3: Find early warning indicators for bear market bottoms and bull market tops

Step 4: Develop Bitcoin 5A Strategy

Step 5: Verify the performance of the Bitcoin 5A strategy

Opportunities and Challenges

Usage restrictions

## Usage Guide:

- Modify the code on the main interface of TradingView, search for the BTCUSD trading pair, and select the BITSTAMP exchange for trading.
- Set the time period to daily chart
- Select Logarithmic Chart in Chart Type to better identify price trends
- In the strategy settings, adjust the options according to your personal needs, including language, display indicators, display strategy, display performance, display optimization, sell alert, buy tip, number of days to open a position, backtest start year, backtest Test start month, backtest start date, etc.

## Step 1: Identify the factors that have the greatest impact on Bitcoin price

*Correlation coefficient: a mathematical concept for measuring influence*

In order to predict the price trend of Bitcoin, we need to dig deeper into the factors that have the greatest impact on Bitcoin priceThese factors or variables can be represented by mathematical or statistical correlation coefficientsThe correlation coefficient is a measure of the degree of association between two variables, with a value between -1 and 1When the value is 1, it means that the two variables are completely positively correlated; when the value is -1, it means that the two variables are completely negatively correlated.

Take corn and pig prices as an example. An increase in corn prices will usually lead to a corresponding increase in pig prices because corn is the main source of feed for pig farming.In this case, the correlation coefficient between corn and hog prices is about 0.3This means corn is a factor in hog pricesFor another example, if one shooter's performance improves, and another shooter's performance decreases due to increased psychological pressure, then we can say that the former is a factor affecting the latter's performance

Therefore, in order to find the factors that have the greatest impact on the price of Bitcoin, we need to find the factors with the largest correlation coefficient with the price of BitcoinIf through the correlation analysis between Bitcoin price and on-chain data, it is found that a certain on-chain data factor has the largest correlation coefficient with Bitcoin price, then this on-chain data factor can be determined as the factor that has the greatest impact on Bitcoin price.After calculation, we found that the number of Bitcoin blocks is one of the factors that has the greatest impact on the price of Bitcoin.It is obvious from historical data that the number of Bitcoin blocks and the direction of Bitcoin price changes are basically consistent.Through the analysis of data over the past ten years, we came to the conclusion that the daily correlation coefficient between the number of Bitcoin blocks and the price of Bitcoin is 0.93

## Step 2: Establish a Bitcoin price prediction model

*Prediction model: What formula is used to predict Bitcoin price? *

Among various prediction models, linear functions have become the preferred model due to their higher accuracy.Taking standard body weight as an example, the image of its linear function is a straight line. This is why we choose the linear function model.However, the price of Bitcoin and the number of blocks are growing extremely fast, which does not conform to the characteristics of a linear function.Therefore, in order to make the two more consistent with the characteristics of linear functions, we first perform a logarithmic transformation on the twoObserving the logarithmic plot of Bitcoin price and block number, we can find that after logarithmic transformation, the two are more consistent with the characteristics of a linear functionBased on this characteristic, we choose a linear regression model to build a prediction model

As can be seen from the picture below, the actual red and green K lines fluctuate around the predicted blue and green lines.These forecasts are based on Bitcoin’s fundamental factors that underpin Bitcoin’s value and reflect its reasonable valueThis picture is consistent with the theory of "prices fluctuating around value" proposed by Marx in "Das Kapital"

Bitcoin’s predicted logarithm of market capitalization is calculated by the modelThe specific calculation formula for Bitcoin price prediction is as follows:

btc_predicted_marketcap = math.exp(btc_predicted_marketcap_log)

btc_predicted_price = btc_predicted_marketcap / btc_supply

## Step 3: Find early warning indicators for Bitcoin’s bear market bottom and bull market top

*Early Warning Indicators: How to judge whether the Bitcoin price has reached the bottom of a bear market or the top of a bull market? *

By observing the above logarithmic prediction chart of Bitcoin price, we find that at the bottom of a bear market, the actual price is often lower than the predicted value; while at the peak of a bull market, the actual price exceeds the predicted value.This rule shows that the deviation between the actual value and the predicted value can be used as an early warning signal.When Bitcoin price deviation is low, a chart with a green background usually means we are at the bottom of a bear market; conversely, when Bitcoin price deviation is high, a chart with a red background indicates that we are at the top of a bull market

This rule has been verified by six bull markets and bear markets. The deviation value does have an early warning effect and can be used as an important reference indicator for us to judge market trends.

## Step 4: Develop Bitcoin 5A Strategy

*Strategy: When to buy or sell, and what quantity to choose? *

We introduced the Bitcoin 5A strategyThis strategy requires us to generate trading signals based on the critical values of early warning indicators, conduct simulated trading, and collect performance data for evaluation.In the Bitcoin 5A strategy, there are three key parameters: buy warning indicator, batch trading days and sell warning indicatorThe number of trading days in batches is to ensure that after the trading signal is sent, we can trade in batches, thereby buying at a lower price, selling at a higher price, and reducing transaction impact costs.

In order to find the optimal early warning indicator threshold and batch trading days, we need to repeatedly adjust these parameters and conduct backtestingBacktesting is a method established by observing historical data that can help us better understand market trends and trading opportunities.

Specifically, we can find key trading points by looking at the Bitcoin Price Logarithm and Bitcoin Price Deviation plotsFor example, on August 25, 2015, the Bitcoin price deviation was at the lowest value -1.11; on December 17, 2017, the Bitcoin price deviation was at the highest value of 1.69; on March 16, 2020, the Bitcoin price deviation was at the highest value of -1.69 The deviation was at the lowest value of -0.91; on March 13, 2021, the Bitcoin price deviation was at the highest value of 1.1; on December 31, 2022, the Bitcoin price deviation was at the lowest value of -1

In order to ensure that these five key trading points can generate trading signals, we set the lowest value of the early warning indicator Bitcoin price deviation to -0.9, the larger of the three lowest values, and the highest value to two 1, the smaller of the highest valuesThen, buy when the early warning indicator Bitcoin price deviation is below -0.9 and sell when it is above 1In addition, we set the number of trading days in batches to 25 days to achieve the strategy of average buying and selling.Within 25 days, we put the total funds into the market evenly, buying once a day; at the same time, we also sold positions according to the same rhythm, selling once a day

*Adjusting the critical value: a key step in optimizing trading strategy*

In order to pursue higher performance, adjusting the critical value is an indispensable stepThe following are suggestions for adjusting the batch trading days and early warning indicator thresholds:

**Batch trading days**: Try different days, such as 25 days, to observe its impact on overall performance**Buy and sell thresholds of early warning indicators**: Exhaustively iteratively tune the buy threshold -0.9 and the sell threshold 1 to find the best threshold combination

Through this detailed adjustment, we may find an optimization plan with a lower maximum drawdown rate (for example, 11%) and a higher cumulative return on closed transactions (for example, 474 times)The picture below is the Bitcoin 5A strategy backtest transaction optimization diagram, which provides us with a visual display of strategy adjustment and optimization.

In this way, we can better grasp market trends and trading opportunities, thereby achieving a more robust and efficient trading strategy

## Step 5: Verify the performance of the Bitcoin 5A strategy

*Verify the accuracy of the model: How to judge the accuracy of the Bitcoin price model? *

The accuracy of the model is expressed by the coefficient of determination R square, which reflects the matching degree between the predicted value and the actual valueI divided all historical data into two groups from August 18, 2015, and used the data from August 18, 2011 to August 18, 2015 as training data to generate the modelThe calculation results show that the coefficient of determination R-squared during the training period from 2011 to 2015 is as high as 0.81, which shows that the accuracy of the model is quite high.As you can see from the logarithmic Bitcoin price prediction chart below, the predicted values don’t deviate too far from the actual values, which means that most of the predicted values explain the actual values well.

The calculation formula of determination coefficient R square is as follows:

residual = btc_close_log- btc_predicted_price_log

residual_square = residual * residual

train_residual_square_sum = math.sum(residual_square, train_days)

train_mse = train_residual_square_sum / train_days

train_r2 = 1 - train_mse / ta.variance(btc_close_log, train_days)

*Verify the reliability of the model: How to confirm the reliability of the Bitcoin price model when there is new data? *

The reliability of the model is achieved through model verificationI set the last day of the training period to February 2, 2024 as the "validation group" and used this as validation data to test the reliability of the model.This means that after generating the model, if new data becomes available, I will use this new data with the model for predictions and then evaluate the accuracy of the modelIf the coefficient of determination when using the validation data is similar to the coefficient of determination during previous training, and both remain at a high level, then we can consider the model to be reliable.The coefficient of determination calculated from the data in the validation period and the prediction results of the model is as high as 0.83, which is similar to the previous 0.81, further proving the reliability of the model.

*Performance evaluation: How to accurately evaluate historical backtest results? *

After detailed strategy testing, in order to ensure the accuracy and reliability of the results, we need to conduct detailed performance evaluation of the backtest resultsKey evaluation indicators include:

**Net worth curve**: As shown by the rose red line, it intuitively reflects the growth of the account’s net worthBy observing the equity curve, we can understand the overall performance and profitability of the strategy

The basic attributes of this strategy are as follows:

Trading range: 2015-8-19—2024-2-18, backtesting range: 2011-8-18—2024-2-18

Initial capital: 1000USD, order size: 1 contract, pyramid: 50 orders, commission rate: 0.2%, slippage: 20 ticks

In the strategy tester overview diagram, we also obtained the following key data:

**Net profit margin of closed trades**: up to 474 times, far exceeding the benchmark, 210 times Bitcoin buy and hold in the strategy tester performance summary chart**Number of closed transactions and winning percentage**: All 100 transactions were profitable, which demonstrates the stability and reliability of the strategy**Retracement rate and profit-loss ratio**: The maximum retracement rate is only 11%, far lower than Bitcoin’s 78%The profitability factor, i.e. the win/loss ratio reaches 500, further proving the advantages of the strategy

Through these detailed evaluations, we can clearly see the excellent balance between risk and reward of the Bitcoin 5A strategy

## Opportunity: Capture changes in factors

Changes in factors provide us with valuable trading opportunitiesThe orange line in the chart below represents the factor indicator. When its value on February 20, 2024 is -0.32, which is greater than the threshold of -0.9, this may be a signal worth paying attention to.Opportunities like this don’t come up very often, so we need to be alert and act quickly

## Usage restrictions: policy application in specific situations

Please note that this strategy is specifically designed for Bitcoin and may not be applied to other assets or markets without authorizationIn actual operation, we should make prudent decisions based on our own risk tolerance and investment objectives

## Free Trial

You can first try out the Bitcoin 5A strategy - Price Upper & Lower Limits for free, click "Add to My Collection". Alternatively, click on the metrics on the TradeView main graph and search for "Bitcoin 5A Strategy - Price Upper"& Lower Limit@Lilibtc ”Click on the asterisk in front of the bookmark to use it.