Can I Build My Own Expert Advisor (EA)?
Building your own trading algorithm can be pretty tricky as it requires lots of – correct – steps to take to produce even the slightest of good results.
Regardless, in reality, it can only take you just up to a few hours to get started building your first EA, even when taking a lengthy and timely process into mind. That depends, of course, on whether you decide to take on coding for yourself.
The best way to start is with as much support as possible.
If you don’t want to spend a lot of time learning a programming language, which is preferable if you want to develop your first realistic trading machine, you can always hire someone to do the job.
You Don’t Need to be a ‘Nerd.’
You don’t need to be the brainiest coder in the world’s largest multi-billion dollar hedge fund (known as quants) to build a trading algorithm successfully.
In fact, you don’t need to have any programming skills at all. Zero.
All you need is a good trading strategy, a small budget, and a lot of patience. Not as hard as you thought now, is it?
So, if you have already considered building your own EA, read along. You will definitely reduce the psychological hurdles attached to decision-making, and along with that, some of the uncertainty regarding the performance of your trading account.
How Hard Can It Really Be?
You will hear that developing a good trading strategy for tomorrow’s markets is an arduous task. And you are better off picking five to ten stocks, tracking their performance, and killing the low performers.
Feel free to try that out yourself. (For me, that isn’t really a strategy. I won’t be revealing my trading strategies here, but I can tell you that during my first EA tests, I discovered many vulnerabilities as I was going through the process of building it.)
Analysing the forex market is not a simple job. So, if you struggle on the strategy front as well, it’s wise to let someone else do the work for you here as well.
You should know that predicting the market is even more challenging. There are infinite indicators at your disposal and endless possible rule combinations you can test. But trust me, you don’t want to start adding a million rules to your EA, assuming it will see improved performance.
And you shouldn’t just look to an average crossover either; that’s merely a strategy.
The right approach any trader can follow is to generate predictive models by converting technicals into market signals. That way, you at least know when to take action yourself or design your expert advisor so that it does that for you.
Trading is about more than just indicators and sentiment, though. It can be influenced by geopolitical factors, economic factors, and, apparently, tweets! However, don’t forget that all of those events are priced in the market data.
The good thing is that algorithmic trading systems intend to do most, if not all, of the trading on your behalf. They are programmed to respond to changes using historical data as a guide and your strategy rules as a signal.
That said, building and automating a trading strategy from scratch is not as easy as a-b-c. However, we can avoid a few basic mistakes when working on our first EA, and all of them subsequently.
Once we eliminate those, things will undoubtedly look and indeed become more effortless.
Main Mistakes Rookies Make
In trading, even the best traders make mistakes because there are so many possible trades. But the biggest mistake of all is not preparing for risks.
Based on my research and experience, we can only create a robust baseline for our automated trading strategy when we avoid these simple yet effective flaws:
Mistake numero uno: Applying the same strategy to different assets
“There is no Holy Grail.”
If you think you have built an excellent EA strategy for a particular currency pair, stick to it.
For instance, let’s assume your EA working works very well on EURUSD. However, it is poised to be very limited with the same settings on EUR/GBP.
The former is the most tradeable pair in the forex markets, offering more substantial and more frequent price movements when compared to the latter.
Think about this for a minute: An RSI 70% sell signal on EURUSD might not be as accurate on EURGBP. That doesn’t make the RSI a poor option for EURGBP. It proves that the RSI might be better for signaling a different condition.
For example, an RSI 80% read might perform better, or, instead of using the RSI 80% as a sell entry indicator, you might notice that it works better as a buy entry indicator or that the RSI 50% makes a good exit instead.
Applying the same strategy to different assets is the right way of finding new uses of a solid strategy for other assets. You can accomplish that by playing around with the backtest settings of a baseline, robust strategy.
Mistake numero dos: Using same conditions for short and long trades
“Markets don’t rise as fast as they fall.”
When backtesting your EA, you should always take good notes of the trading statistics.
In particular, to understand how good your EA strategy works, you need to identify the number of trades not as a total but independently; longs and shorts.
You can not assume that the conditions you have set for shorts and longs, which always work for both buying and selling – unless you have blocked one out – will yield the same good results.
Markets move at different speeds and patterns are different when they fall versys when they rise, right?
There are rare cases where you get an equal number of shorts and longs, which somewhat counterbalances the risk of inclusion. However, in most cases, it is the risks of sampling that we have to face. Let’s look at an example to understand sampling a little bit better:
In the above backtest, you can see a total of 163 trades, 79 are shorts, and 84 are longs – quite a nice balance.
It is clear that during the backtest period, the winning ratio is abysmal for both directions at 25.77% on average; it depends on entry and exit rules. However, the purpose of this example is to showcase why longs and shorts are different strategies.
Out of the 167 trades the EA placed, we scored a 21.52% winning ratio for shorts and 29.76% for longs. Regardless many would probably go live based on the total net profit of $1085.31. After a few months of live EA trading, though, they could realise that if they had cut out shorts, their EA’s performance would look like this (without shorts):
Apart from always separating the two, however, there are a few more things to note down.
First, note that the number of trades makes a reasonable sampling period to backtest in our case. Depending on how long your backtest period is, however, you should have at least 50 trades per backtested year in your books. Incorrect sampling adds significant risks to your EA’s performance.
Second, the 20% drawdown we achieved during the backtests is from a combination of a good and a bad strategy. You take on risk by throwing an EA in live markets, having neglected the bad trades. Also, you fail to incubate the long strategy accurately.
Finally, you fail to see your EAs performance for what it is. Remember the long strategy we just saw on its own above? Here’s what we can get with a few tweaks (actually two tweaks) instead:
Yes, the total net profit is minimal, the number of trades halves, and the average loss trade is three times the average win.
However, the maximal drawdown is three times smaller, the winning ratio is extremely good at 78.26%, and the amount of in-sample trades makes perfect sense for a portfolio of EAs.
Please don’t get me wrong, though. This still does not constitute a good EA as the drawdown is larger than the growth. Which, by the way, we can once again fix with another simple tweak, improving the profit factor by 25%:
Mistake numero tres: Trading on short-term timeframes
“Don’t let the bid/ask war beat you.”
Many think short-term strategies increase intraday returns, which can, of course, stand the test of time but don’t stand a chance at all if the strategy is based on short-term timeframes.
Although the statement can bring discomfort to a few, mainly scalpers, in reality, using higher period time frames reduces one’s exposure to the risks of volatility and the risks of slippage, spread, etcetera. At the end of the day, why risk 5-10% of your account to only grab 5-10 pips?
What’s more, if you’re going to invest your money in building a short-term strategy, you should at least be doing so with timeframes higher than the 15-minute period as a safety net – waiting for the asset to buy/sell for at least 15 minutes to trigger a break.
The lower the timeframe you use, the higher the risk of noise. Emotional, undisciplined traders mainly produce noise. I’m not sure if you want to jump on that particular bandwagon, but I choose to trade signals, not noise.
While some short-term strategies can result in an excellent performance curve during backtests, it is essential to remember that the main reason such a strategy will fail in the live markets is your own failure to feed the correct data to your backtesting environment.
By that, I mean when you backtest your EA, you have to add at least the spread of the broker you will deploy your EA on, not some random, fixed spread number.
Only if you are sure your broker will open a fixed account for you and you have access to the spreads table can you use ‘variable spread.’
Mistake numero cuatro: Allocating a fixed lot size
“Diminish the Law of ‘Diminishing Returns”
In general, when trading forex, the lot size will undoubtedly affect your net exposure and your profit per trade. Therefore, by understanding how to position, you will improve the EA’s ability to manage risk and return your account.
To gain some insight into this, let’s look at some trading examples that have used the same price targets and different lot sizes.
This is a peak in backtesting EURUSD over few months (2019.10.01 – 2020.02.01), with timed-based multiple take profit management and a candle-based stop loss, first with fixed lot size (1 lot), then with balance allocation (1%) and risk allocation (1%) methods. The results are outstanding:
Backtest – Fixed lot size based on 1 Lot per trade:
Backtest – Variable lot size calculated as 1% of the account balance per trade:
Backtest – Variable lot size calculated as 1% of the account balance for each trade’s stop loss:
A quick depiction of the three methods clearly differentiates which investment option stands out, naturally. Despite both the fixed lot size and the balance allocation methods matching this particular backtest, the latter often works better than the former in terms of performance due to compounding.
However, on minimum trades, compounds cannot be systematically applied. But then again, this is a decision to be taken based on risk appetite.
Using a risk allocation method, on the other hand, has its perks. The lot size is calculated based on the stop loss in the risk allocation method, making your EA more dynamic, thus, bringing it closer to market-reality.
This approach is crucial because it offers better risk management, all within an identical underlying market and metrics.
Build By Learning
As you already understand, past mistakes are exactly what creates the opportunity to build your own EA. Especially for those interested, I hope that now things are much more approachable.
It will indeed remain challenging to make an accurate evaluation of the performance of some trading strategies. But I know it is way more manageable, at least. It will also remain difficult to build a successful portfolio of EAs. This one will take its toll – be patient.
Since you now know how to avoid rookie-based roadblocks, perhaps, building your own EA isn’t as difficult as you initially thought!
Author Profile
Stavros Tousios
Info
284 Views 0 CommentsComments
Table of Contents
Recent
-
Bitcoin Fundamental Briefing, March 2024 Demystifying Cryptocurrency Nodes: Deep Dive into Polygon Node Ecosystem Strategies for Trading Forex on a Budget Bitcoin Fundamental Briefing, February 2024 Bitcoin Fundamental Briefing, January 2024 Strategic Asset Allocation Techniques for Currency Traders Bitcoin Fundamental Briefing, December 2023 Bitcoin Fundamental Briefing, November 2023