SUPERALGOS DATA MINING
Honest Backtest : Moving Average Distance Index and RSI Trading Strategy
Backtesting of a strategy found on the web
With this article, we are starting a new series consisting in testing strategies found on the web with Superalgos. In the Honest Backtest articles series, we will review strategies suggested by random people, influencers or unknown, claiming for profits or not, and provide full backtest results with influent parameters identification to see if it is realistic or… just a click bait !
The strategy
The strategy we are going to study uses the Moving Average Distance Index (MADI) and RSI to identify entry points but does not specify exit conditions or risk management. It is a trend reversal strategy, so to close the position we will set the conditions to target the moments where the trend is most likely to reverse using the MADI plus stop-loss and take-profit based on the elastic Volume Weighted ATR.
Relative Strength Index
The Relative Strength Index (RSI) provides information on bullish and bearish momentum. It shows the range of price movements to evaluate oversold or overbought conditions of the market.
RSI is calculated in a two-step process. First we have to proceed to the Relative Strength calculation :
Average gain and average loss are the mean loss and gain over the lookback period, generally 14 for the commonly used RSI.
The RSI is then determined with a normalization of the Relative Strength:
RSI values are framed within 0 to 100 range. RSI crossing 30 level is considered as an oversell condition, statistically leading to a trend reversion to an upward movement, whereas crossing 70 is an overbought condition leading to a downward trend.
Moving Average Distance Index
The MADI is a simple indicator designed to describe the position of the price against its moving average. It is easily calculated with the Z-Normalization of the difference between the price and its 20-periods moving average.
The sequence to process the MADI is as follow :
- Calculate 20-periods moving average on the closing price of the candle
- Subtract the closing price from the moving average
- Perform Z-Normalization of the above result with a 60 periods moving average
- Set Upper and Lower bands at 2 standard deviations from Z
The MADI is plotted as a black curve for the Z-Normalization of the distance from moving average and two blue lines for the upper and lower bands. The 60-periods moving average of Z is also drawn. The MADI can be interpreetd as :
- when Z is below its moving average the trend is downward
- when Z is above its noving average the trend is upward
- if Z crosses the lower or upper bands, the price is very far from its moving average and a reversal is most likely to happen
Strategy Description
The strategy will be executed on long positions by opening a market buy order whenever RSI is below 20 and MADI is below its lower band both on the 01-hs time frame. The goal is to target the point where the market is in an oversold state and the price far below its moving average, highlighting a high probability of trend reversal. We set one situation with two conditions at the “Create order” event node of the Market Buy Order node of the Open stage in Superalgos.
The close stage consist in 3 situations to manage the trade with 2 close at profits, one emergency close at lost, and 2 situations to manage the Take-Profit and Stop-Loss. The whole close stage can be described as :
- Exit with profit : MADI downcross its upper band
- Intermediate exit for worst case profit : MADI downcross its moving average
- Emergency close at loss : MADI downcross its lower band
- Take profit : trailing at Entry rate plus 3.5 time the eVWATR on the 01-hs time frame
- Stop loss : trailing at Entry rate minus 2 time the eVWATR on the 01-hs time frame
The Exit stage is rationally organized to match with the entry conditions. We spot the cases where the trend will have the biggest probability to reverse (close position and worst case profit), then we consider the case of a failed entry (emergency close). Take-Profit and Stop-Loss are set to prevent from cases where none of the 3 close conditions realize.
Backtest results
The strategy is executed on a little bit more than a 1 year time span from 1st of February 2021 until 16th of February 2022, trading conditions evaluated at 01-hs time frame on BTC/USDT market. Exchange fee structure is set to match standard Binance fees : 0.1% Taker/Maker
Base strategy results
The first backtest attempt shows a profitable outcome, well… barely ! The bot took a total of 55 positions with a hit ratio about 0.4. The ROI over the period is 0.945 % where BTC/USDT on the same period achieved 32.6%.
The strategy on this basic version is not worth it. Hit ratio is below 0.5 while ROI is ridiculously low. We propose now to modify some of the entry and exit conditions to see if we can improve the situation.
Switch from RSI to auto-adaptative normalized RSI
We have recently suggested a powerful improvement of RSI to minimize fake signals. This optimized RSI consist in using a Discrete Fourier Transform to determine the dominant cycle of the market and use it as input parameter for the RSI length while using the Z-Normalization to have a probabilistic approach of RSI analysis.
We then modify the entry condition by replacing the condition on RSI while keeping the condition on MADI :
- Auto normalized RSI above its moving average
- MADI below its lower band
We keep the same parameters for the close stage while running the backtest at the same time frame.
The backtest session exhibit a similar hit ratio but with significantly way lower number of trades. The bot achieved 14 trades with 0.4 hit ratio while the ROI reached 3.06 %.
The use of optimized RSI allows to improve the ROI, acting as a filter for a lot of bad trades but the strategy still performs poorly.
To keep the spirit of this strategy we are not going further on the optimization of the open stage and we are now focusing our efforts on the close stage. It is also worth noting ST/TP are already optimized.
Removing the emergency close and the intermediate profit
The same backtest is now performed without the 2 situations used to manage the trade for the wrong turn case and securing an intermediate profit.
The bot achieved 53 trades over the backtesting period with a hit ratio about 0.46. The overall ROI is now 3.66%. The improvement is minor but possibly underlines a too conservative set of conditions at the close stage.
Close stage without the emergency close
We have added the intermediate profit condition while keeping the close at profit situation and SL/TP situations.
The bot achieved 54 trades over the backtesting period with a hit ratio about 0.45. The overall ROI is now 4.66%.
Close stage without intermediate close
Now let us try to remove the intermediate close situation and add the emergency close situation while keeping the other SL/TP and close situations.
With 53 trades, the strategy achieved 0.41 hit ratio and an overall ROI of 10.54%. This is, by far the best result we have seen while backtesting this strategy but still it can’t beat the market. Considering the effort to achieve this result, we consider it will be worthless to go further and at the cost of deeply modifying the initial philosophy of the strategy.
Conclusion
The backtest of the MADI strategy leads to mild results. While it is objectively profitable, the overall performance does not beat the base performance of the BTC/USDT pair or would require more complex refinement to achieve better results.
It is worth noting our backtest does not consider potential leveraging effect that could be available and could significantly change the outcome of the strategy but would also require a definitely different risk management strategy to minimize the risk of liquidation.
This MADI strategy can be found upon the Simple MADI strategy workspace in Superalgos for educational and demonstration purpose, including a dedicated datamine with MADI indicator and RSI. The Open stage can be tuned by adding/removing the floating node present close to the Open Order event.
All the material presented here can be reused and integrated freely on the condition linking to this article and the Superalgos website.
Disclaimer: The content of this article is for educational purpose only and does not constitute financial advice. Trading is not suitable for everybody; seek professional advice. Use this article at your own risk.
If you enjoyed this article and want to participate in the most promising open-source social trading platform… come and join us !
- Superalgos Community : https://t.me/superalgoscommunity
- Superalgos Support Group : https://t.me/superalgossupport
- Superalgos Develop Group: https://t.me/superalgosdevelop
- Superalgos Data Mining : https://t.me/superalgosdatamining
- Superalgos Machine Learning Group: https://t.me/superalgosmachinelearning
- On Discord Server: https://discord.gg/CGeKC6WQQb
- Superalgos en Français : https://t.me/superalgos_fr
- BTC/USDT Telegram Bot : https://t.me/superalgos_tradingBOT_BTC_USDT