MoneyNeverSleep

Moving Average Trend Strategies backtesting (feat. BTC)

Dr.Chae 2022. 12. 8. 13:14

There are Crossover and Crossunder Trend strategies along the moving average line. Although it seems an excellent strategy to use in the upward market, it is necessary to check what results come out when applied, which we can see from Backtesting. In short, it is called backtesting to help check the strategy's overall performance through past data.

Figure 1. Python backtesing code


Figure 1 shows a programming source that collects data from Upbit and Bithumb through a programming language called Python and backtests based on it. I recommend learning Python step by step when you have a chance. There are good references, such as YouTube and Wikibooks, so please refer to them. If I have a chance, I will mention it occasionally through this blog site.

The conditions required before turning the program shown in Figure 1 are as follows. Since it was based on Upbit data, backtesting was conducted until yesterday, when this posting was made based on the Upbit opening date. Upbeat proceeds on the same basis because the candle stick is initialized at 9 a.m. every morning. When trading open for No. 5, when trading data is retrieved, data called ohlc is obtained, indicating open (initial), high (the highest price), low (the lowest price), and close (close price), respectively. It is assumed that it was sold based on the initial price.

1. Initial capital: KRW 100M
2. Start: Upbit Opening Date (October 24, 2017 at 9 a.m.)
3. Termination: May 27, 2021
4. Upbit data daily
5. Sales: 9 o'clock (KST) open standard

Figure 2. Yield Comparison


Figure 2 shows the Crossover/Crossunder strategy results of the 7-day moving average and the 30-day, 90-day, 180-day, and 360-day moving average, respectively, when maintained after the initial purchase. If it just persists, it shows a 662% return, and in order, it shows 1370%, 1221, 738%, and 137%, respectively.

We checked the return as above through the Crossover/Crossunder Cross strategy. However, it is necessary to check the strategy of the current price breaking through the moving average and to collect data every hour or four hours and do the same test. We will proceed with this further next time.