For some time I have been looking into Forex trading and coding an expert bot that can trade with good performance. In this post I present some results from some basic strategies and and some insights.
It turns out that “good performance” is a very subjective term when talking about trading strategies. Since an ideal strategy, which constantly makes you profit through its 95%-of-the-time-successful trades, does not exist, we face a tradeoff when defining good performance. Key performance indexes such as average return, absolute drawdown, maximum drawdown, profit factor, success rate, payoff, etc. are all important when assessing a strategy.
We can have a strategy that has a pretty good success rate, but from time to time, faces a big drawdown: a strategy that makes profit 20 days straight, but then makes a losing trade that cancels out half the profit of those 20 trades all at once. You cannot present this strategy to an investor. Or one that makes 1000 trades per day, with a very low expected return per trade: total win of 2,100$ and total loss of 2,000$ gives 100$ profit by the end of the day, but is it worth the risk, the fees, etc.?
I used MetaTrader for a long period, but it never occurred to me how valuable its backtest function is, until the day I wanted to test some strategies on crypto. I could not find a user-friendly backtest tool and had to write the code myself. And believe me, writing a backtest code is not fun. Anyways, after coding different strategies in MQL4 and many backtest & optimization cycles in MetaTrader, I came to an obvious conclusion: no single strategy can make profit in long term with good performance.
Each strategy can be regarded as an asset in our portfolio. We can get closer to a “good strategy” the same way we optimize our portfolio’s risk & return: through diversification. And there is a plus here: in portfolio optimization we have different assets cover each others’ losses. With trade strategies, not only we can do that, but we have also the possibility to use different assets confirm each other.
Lets see some early results now. What I did was to put these three strategies
– RSI divergence (weak and strong)
– MACD crossover
– MACD divergence (weak and strong)
into MQL4 code and optimize them separately over a certain period of time. Then, let them run together.
The first test that I always do to verify the potential of a strategy is cheat-training: training and testing it on the same data. This will show you that you have a strategy that is at least capable of making profit. Here you see the balance graph of the strategies separately and together with cheat-training on 2020-2023, 1H, EURUSD:
It is clear how the first one is smoother that the rest. Here I am using different strategies to cover each other. The following is the performance report of the three strategies together. To summarize the table below: Had you trained well this trading bot in May 2020, it would turn your 300$ into 3,353$ three years later, in May 2023! And along the way, your money would never go below 296.50$. This is without compounding. Of course I am considering a 100x leverage, which is an average one for Forex and EURUSD pair fans. I must mention that on this raw account, I have spread of 0 for this pair, but 3.5$ fee per lot. So a real world estimation for the 421 trades would face a total fee of 147$, which shall be deducted from the profit.
The cheat-training showed that the idea has some potential. For the next test, I did something different. I trained the strategies for the period of 2009-2014 and then tested them for a period of 23 years: 2000-2023. I wanted to see if the diversification can make a robust strategy, which needs minimum continuous training and can be tested in forward and backward direction! Here are the balance graphs.
I summarized some key performance parameters of each single strategy and the overall one in the following table. Both the graph and the table show that in long term, too, mixing strategies can get rid of the significant ups and downs of each single strategy.
Still, this is not a good performance. Of course! We shouldn’t expect good performance from a 500-line code, which is trained for a period of 5 years and then tested over around 10 before plus 10 years after the training period! I could do proper training and testing with a sliding window over the 23 years period, but looking at the number of input parameters that I have to optimize each time, it will take a very long time.
For the next steps I am thinking about the following
– Redo the 23-years back-test with a 3-year sliding window: 2 years training + 1 year testing
– Add another strategy to have better diversification
– Adjust trade size of each strategy based on its risk & return
– Move towards having different indicators confirming each other, in addition to covering
1 thought on “(Forex 01) Diversification with RSI and MACD (MQL4 MetaTrader)”