Ready to build some winning trading strategies and boost your Expert Advisor portfolio?
This post contains a step-by-step tutorial on how to create trading strategies that are working GREAT and produce AWESOME results on historical price data.
Let’s get started!
Introducing: Forex Robot Factory
I use an online EA Generator tool called Forex Robot Factory. It is one of the best and fastest ways to create trading systems.
If you follow this tutorial, in just one hour, you can create at least a few strategies with impressive backtest results and high-performance stats.
Don’t have an account to Forex Robot Factory?
No problem. You can get your FRF 15-day trial here. Signup only takes a couple of minutes.
Okay, so now when you’ve created your FRF trial account, we can continue with the tutorial.
Forex Robot Factory (FRF) is a potent tool. Don’t underestimate it.
By the first look, it might seem too confusing, packed with many settings and features. However, trust me, once you learn a few necessary steps on how to use the FTF tool, it becomes easy to create trading systems.
Think of it like a car. Every car has lots of buttons, a dashboard full of notifications and numbers, etc.
However, you don’t need to learn all of them, at least to start driving. You know the accelerator, and you know the brakes, the wheel, and how to shift gears.
Everything else in the car is mostly for your convenience.
I like saying that you’ll find the solution when you get to the problem. Don’t look for the solution until you haven’t met the problem.
Is it too hot in the car? Now you need an air conditioner. It’s time to learn how to use it.
I am sure you get the point.
So if something seems confusing in the FRF for you, don’t mind it. You probably don’t need that button now anyway.
When you open the FRF Expert Advisor Generator, you’ll see the menu at the top and some tables.
1) The main menu has many tabs, but we’ll need just a few.
“Generator” tab is where you create trading strategies.
“Collection” tab is where all created strategies are added.
“Strategy” tab is where you can edit the selected individual strategy.
“Tools” tab is where we can set various settings for the FRF tool.
“Help” tab is where you should look for help if you don’t understand something in the FRF tool. Most of the functions are described there. However, please finish reading this tutorial (better read it twice) before asking any questions. I am sure you’ll find your answers later in this tutorial.
2) Must be logged in to use all the functions of the FRF. Get your Forex Robot Factory trial account here.
3) Choose your preferred language.
4) Useful links. Highly recommended to look through these resources.
Okay, so enough of this boring stuff.
Let’s get started.
Using Expert Advisor Generator to Create Winning Trading Strategies Without Programming
Choose currency pair and a timeframe for your strategy
Usually, I design each strategy for one timeframe. In rare cases, a strategy might produce good results on multiple timeframes. However, that would produce a different sequence of trades, and therefore, we treat it as a separate strategy.
In this tutorial, I use EURUSD and a 1-hour timeframe.
Historical price data source I use is from FXOpen-ECN Live Server. It’s possible to use your broker price data, but we won’t cover this now, and it isn’t that important after all.
My selected Data source has 10 years of historical price data. That’s quite a lot of historical backtesting of trading strategies.
Choose strategy parameters
We have to set strategy parameters as lot size, stop loss, etc.
In this example, I choose 1.0 lot size for each trade.
I set FRF to always use the stop loss for each strategy it creates. The stop loss should be between 50 and 200 pips.
I also choose to always use the take profit within a range of 200 and 1000 pips.
Note that my risk to reward ratio for each strategy is minimum 1:1 and maximum 1:20.
Minimum TP of 200 pips divided by maximum SL of 200 pips is equal 1:1 risk to reward ratio.
Also, a maximum TP of 1000 pips divided by minimum SL of 50 pips is equal 1:20 risk to reward ratio.
Also, note that strategies have exit rules by indicators which might close positions earlier before hitting SL or TP.
Define Generator settings
I set the FRF to work for 60 minutes and search for strategies with the highest Net balance. Once I click the START button, the FRF starts generating strategies for 60 minutes and then stop. You can set any number you like.
For example, if I start the Generator on Friday and leave it to work during the weekend, I would set Working minutes to 5000. That’s how I can keep FRF running for 3 days. Note that you cannot close the web-browser window and the FRF tool must be visible all the time to continue working.
I did not set FRF to use Out of sample to not complicate things.
Also, FRF is set to use the standard Acceptance Criteria to determine if the generated strategy should be added to the Collection or not.
Let’s see what Acceptance Criteria I use in this example.
Defining Acceptance Criteria
It is the place where you tell which strategies should the FRF add to the collection.
In other words, if the generated strategy does not meet these defined criteria, FRF won’t add it to the collection and continue to create new strategies.
My Acceptance Criteria is quite simple:
1) Minimum backtest quality. Leave it at 10. To not overcomplicate things I won’t explain it here.
2) Minimum net profit of $10. It could be a higher number, but before you use something else, first get familiar with what strategies you get.
3) Minimum count of 100 trades. Usually, I would want more trades, especially during the 10 year backtesting period. However, I don’t want to set this number too high because we might not see any strategies generated.
4) Minimum return/drawdown of 3. Ideally, I am looking for strategies with a minimum return/drawdown of 5. However, I go through the list in the collection manually to find them.
Don’t be too strict with Acceptance Criteria, or you might not see any strategies.
Traders often have unrealistic expectations and want strategies doubling your capital every month with a max drawdown of 5%, stop loss of 20 pips and a profit factor of 3.
It is not going to happen because such strategies do not exist. If you are the one who is looking for such a strategy, then you need to grow up. If you feel offended then, well, someone has to tell you the truth.
Choose a list of indicators to use
I set the Forex Robot Factory to use the recommended list of indicators when creating strategies.
Every strategy needs a minimum one entry rule and one exit rule indicators.
In the Settings section, I set the FRF to use the account of 10,000 USD with a leverage of 1:100 when backtesting trading strategies.
Also, by default, FRF is configured to start the backtest from bar 100 and close any open positions at the end of the backtest. It is to mimic the behavior of MT4 backtest. You should leave those settings switched on.
I don’t use Trading session, so I leave it as is. It means strategies are allowed to enter and exit trades with no time restrictions.
For Correlation analysis, I select both filters and the threshold of 0.98. It prevents FRF from adding very similar strategies to the Collection. For example, you don’t want strategy using Moving Averages crossover of 10 and 50, and another strategy using the same MA crossover of 11 and 51. They are the same. FRF keeps the one which produces better results.
I set the Forex Robot Factory to use the recommended list of indicators when creating strategies.
Every strategy needs a minimum one entry rule and one exit rule indicators.
Start the EA Generator
I have set all the necessary settings, and now I am ready to start the EA Generator.
Strategy generation in progress
When the Generator is running, you’ll see the Generator tab turn red.
Progress shows how much time has already passed in percentage (according to Working minutes).
According to my settings, the Progress should hit 100% when the Generator runs for 60 minutes.
Note that FRF uses random generation, and if you start and stop the Generator multiple times, it does not affect the quality of strategies or anything like that. Every time you start the Generator, it is entirely random.
Don’t worry if you stop the Generator before it finishes and before the Progress hits 100%. It is random every time.
Generator Finished The Job with 53 Winning Trading Strategies
In 60 minutes, the Generator created and tested 61,472 strategies, and 53 of them passed my Acceptance Criteria and Correlation filters.
Now I have 53 trading strategies in my Collection. I choose the best 5 strategies and export them as MT4 Expert Advisor for automated trading.
I can see their exact trading rules and parameters, which means I can use them for trading Forex manually should I want to.
Sorting Strategy Collection
When I switch to the Collection, I see the list of all the strategies inside.
The Collection displays 10 strategies per page, so you need to scroll down and up and switch through pages to see all the strategies.
I prefer to sort the Collection by Return / Drawdown. This way, I can see the strategies with the highest R/D at the top.
Removing Poor Strategies
It gives lots of experience if you’ll go through the list of strategies manually and remove the ones that look poor.
It is possible to use performance filters to do this automatically, and I’ll do that soon, but I want to show you that it can be done manually too. When you start your long journey in Algotrading, it is best to see as many strategy possibilities as possible.
I remove the strategy 46.1 because it has a small number of trades. 137 trades over 10 years are quite low.
A year has 52 weeks, so we have 520 weeks during our backtesting period of 10 years.
137 trades are about 1 trade every 4 weeks on average.
Does not mean you cannot use such a strategy, but today I’ll focus on strategies which produce at least a few trades per month.
In other words, I’ll focus on strategies with around 500 trades, which means it should produce one trade per week.
Using Performance Filters to hide or remove poor strategies
I turn on performance filters and add a few validation criteria.
To add additional performance filters, use the “Add validation criteria” button when the performance filters feature is enabled.
As you can see, there are lots of filters available to fit your needs.
I add two performance filters.
1) Minimum return/drawdown of 5.
2) Minimum count of trades 520.
Filtered strategy list
My performance filter matches only 2 trading strategies out of 52.
Those are strategy 16.1 and 31.1.
Let’s see what’s inside the strategy 16.1 by clicking on it.
Inside the Strategy
When you click on any strategy in the Collection, it loads the strategy in the Strategy tab takes you there.
Inside, you can see all the available information about the strategy.
We can see trading strategy rules which we can use for manual trading.
There are three main sections to define the strategy:
- Strategy Properties;
- Long entry;
- Long Exit;
Note that all strategies created by FRF are symmetrical, which means we get to choose entry and exit rules only for Long positions (BUY signal). For short positions (SELL signal), it’s always the opposite.
For Strategy 16.1, we have a Stop Loss of 72 pips, Take Profit of 249 pips, entry using the Money Flow Index indicator and exit using the Envelopes indicator.
To see the exact entry/exit rules and indicator parameters, we have to click on them.
Entry Rule Indicator parameters
When we look inside the entry rule, we see that it is as follows:
Go Long when 42-Period Money Flow Index indicator crosses the 39 Level line downward.
If you want to trade this strategy manually, you can quickly identify these entries on any trading platform and then open a BUY trade with SL of 72 pips and TP of 249 pips.
Exit Rule Indicator
Exit rule indicator says the following:
Close BUY trade when the price bar opens below the Lower Band of the 30-Period Envelopes indicator applied to the Close price (MA method = Simple and Deviation = 0.77%).
Might sound confusing, but when you plot such indicator on any trading platform, it is easy to spot when the bar opens below the lower band.
Short entry and exit rule is always the opposite of Long
As I was saying earlier, Short entry rule is always the opposite of the Long entry rule.
So if Long entry rule is “MFI crosses the Level line downward“, then the Short entry rule is “MFI crosses the Level line upward“.
The same with exit rule.
There’s a sub-menu below the main menu which allows you to run many additional checks on the strategy like Optimization, Monte Carlo, Walk Forward, etc.
I would say those are for the next level. To not overcomplicate things, we do not go through those features in this tutorial.
However, let’s take a look at the Report of the strategy.
There’s a Stats Info section in the Report tab which shows various statistical data of the strategy backtest.
We cannot know if our strategy produces the same results in the future should we trade it live, but since no one knows the future, those stats are the best we have. Backtesting results gives us expectations for each strategy, but it does not mean the strategy continues to work that way.
After looking at the stats above, I can say the pros and cons of this strategy.
- Count of trades more than 500 over 10 year period. It means approximately 1 trade per week. I know many of you want multiple trades every day, but that’s how you burn your account if you force the same strategy to give you as many entries as possible. Plus, you pay more for commissions, spread, and slippage. Focus on quality, not quantity.
- Return/drawdown of 6.17. That’s a good number. I consider anything above 5 is good and anything above 10 is excellent.
- Max consecutive losses of 14. It is not mainly a bad thing, but I know all you newbies out there always lose patience after the 4th loss in a row. However, that’s your problem. The ones who stay in this game long term always wins.
- Max drawdown of 37%, which is $12,330. That’s bad. Everyone has their preferred risk appetite, but I would like to see a max drawdown of 15% on the backtest because in real life it can be even higher in the long term. I am okay with 20% but would like to limit my strategy creation to 15% max drawdown when possible. However, percentage drawdown is not the worst part. The worst part is the monetary drawdown of $12,330. Remember that we start with $10,000 and such account would not handle the drawdown this big. I’ll discuss this later in the tutorial.
Monthly performance in currency
When looking at monthly performance, it looks quite good I must say.
It is not perfect, but it is good.
Remember, perfect strategies with perfect equity curves that do not have any losing week are too good to be true. Usually, they use some tricks to show you that perfect equity curve.
In FRF, each strategy never has more than one trade open at the same time (unless you combine multiple strategies into Portfolio). Moreover, FRF strategies never use martingale, grid trading, or any dirty tricks like that. This fact adds lots of confidence.
Indicator chart with visual strategy entries and exits
If I switch to the Indicator Chart section, I can observe each entry and exit on the chart with indicators.
Use + and – buttons on your keyword to zoom in and out.
Use Ctrl+Arrow (Left/Right) on your keyword to go to the next or previous entry/exit point.
Hover your mouse on the chart for detailed information.
Balance Chart section
In the Balance Chart section, I can see the equity curve of the strategy and other useful charts.
Like for example, the green and red lines on the chart represent the equity curves of BUY and SELL trades respectively. The gray line represents the market price, in my case, the EURUSD.
Ideally, we want to see the green line trending upwards when the gray line is trending upwards and the opposite for the red line.
If for example, the red line is going down when the gray line is going up, it means the strategy hopelessly is trying to short the market when it is trending up. Such a strategy won’t take you far.
Lowering Trading Strategy Risk
Because this strategy has a large drawdown, let’s try to lower its risk.
I don’t know how much risk to set precisely, so I’ll keep changing the lot size until the max drawdown is less than 15%, but the Net Profit is still around $10K.
I click on the Strategy Properties to change the lot size.
Let’s try 0.5 lot size.
With the 0.5 lot size, the strategy max drawdown is 25%.
Let’s lower the lot size again.
Let’s try 0.25 lot size.
Max drawdown is 17%.
Let’s bring it down some more.
Let’s try 0.15 lots.
Great. Max drawdown is 12%, and the Net profit is above $11K.
Exporting Trading Strategy as Expert Advisor for Automated Trading on MT4 or MT5
Now that Strategy 16.1 has reasonable risk and return, I can export it in the MT4 format so I can use it for automated trading.
MT4 (or MetaTrader 4) is the most popular trading platform which allows anyone to benefit from automated trading.
The hard part was that before the Forex Robot Factory existed, it was tough to create automated trading strategies (a.k.a. Expert Advisors) for MT4.
However, now, you can create a bunch of fully automated in just an hour. How cool is that?
Choose the next strategy from Collection
Now I choose the next strategy from the Collection, Strategy 31.1.
I take a look at what max drawdown it has in the Stats Info section.
It is 88%. Wow! That’s big.
Let’s bring its risk down.
Switch to Editor section and set the lot size to 0.15.
Let’s see what max drawdown we’ll get now.
Max drawdown got down to 19%. That’s still a bit higher than I would want to see, but it was 88%. So that’s a significant change.
Save Trading Strategy as MT4 Expert Advisor
The second strategy is ready, and I export it as an automated trading robot (Expert Advisor) again.
I adjust the performance filters now to have a bigger list of trading strategies. I want to export 5 strategies. I already have 2, so 3 more left to find.
Before I adjust the filters, I remove both exported strategies from the Collection so that I won’t end up exporting them again later.
Adjusting Performance Filters
I have removed the minimum amount of trades filter, and now I have 4 new strategies appear in my Collection.
I repeat the same procedure for three more strategies like I did with the previous two. That is to lower the lot size to make the max drawdown lower, and then, export in MT4 format for automated trading.
Note: If you are using MT5 trading platform, you should export MT5 format.
Installing Expert Advisors into MetaTrader 4 account
Navigate to the Downloads folder
After I export all 5 trading robots, I open the Downloads folder.
Select & Copy Expert Advisor Files
I select all 5 MT4 Expert Advisor files (they have MQ4 extension) and choose Copy in the right-click menu.
Switch to MT4 terminal and Open Data Folder
To install those trading robots into my MT4 trading platform, I need to open Data Folder from the File menu.
Paste Expert Advisor files into MT4 Data Folder
Inside the Data Folder, I need to go two levels deeper.
Navigate to MQL4 folder and then to the Experts folder.
The folder where to copy EA files:
All 5 trading robots are now in the MT4 Data Folder.
Refresh Expert Advisors list in MT4
Before I can use these newly installed trading robots, I need to refresh the Expert Advisors list inside my MT4 Navigator window.
Here they are — all five MT4 robots on my trading platform.
Open five EURUSD H1 Charts
Now, I need to open five EURUSD 1-hour charts.
A chart for each EA.
Turn On Automated Trading
By default, Autotrading is disabled in MT4, so I need to enable it from the top toolbar.
After I enable Autotrading, I can now proceed to start all trading robots.
Starting MT4 Expert Advisor
To start the MT4 trading robot, I need to drag and drop it on the chart.
Before the EA starts, it shows EA Properties window.
In the Common tab, make sure the “Allow live trading” is selected.
Next, switch to the Inputs tab where all EA strategy parameters are listed.
It is where you can change these parameters. However, I do not recommend it because it would change the strategy, and you won’t know what to expect from it.
The only parameter you can change is Entry Lots to fit your account size.
In my case, I have the same size $10K demo account, and I keep the Entry lots as is.
Click OK to start the EA.
When I attach a robot on the chart, I see a smiley face in the right top corner.
Don’t expect it to open a trade immediately (although it can happen). Don’t expect EA to open a trade the same day or even the same week. It might take time. It could open a trade the same day or the same week, but if it won’t, don’t panic.
Remember, EA is following the strategy and its entry/exit rules. It won’t open trades just for the sake of opening them or because you want “some action”.
EA patiently waits and monitors EURUSD price until the indicators align and meet the entry rules. Only then it opens a trade.
You saw trading rules of each trading strategy in the FRF, and you can easily plot the same indicators on the chart with the EA. This way, you can visually see when a potential trade signal is forming.
Load All Five MT4 Expert Advisors
Repeat the steps to load all 5 trading robot in your MT4.
Now you have a Portfolio of 5 trading robots.
So what’s next, you ask?
Patience, patience, patience!
Patience is something most traders don’t have. However, that’s one of the most common reasons why traders fail to win.
Keep running these robots 24 hours per day all week for 3 months.
Closely watch trading results of your trading strategies. Pay attention to the max drawdown, consecutive losses, amount of weekly/monthly trades, etc. If any of those stats become significantly worse, then consider replacing such strategies.
Ideally, you should create more robots for other currency pairs too.
Have many trading robots running on demo test (we call this incubation). That way, you always have strategies with several months of trading results ready to be moved to live trading account.
The more strategies you are running in incubation, the higher your chances that after several months you’ll find trading robots that perform well.
Monitoring Multiple MT4 Trading Robot Strategies On The Same Account
When you are running more than one trading strategy on the same MT4 account, it becomes close to impossible to tell the results of each strategy.
All trades are a part of the same account history. While 4 strategies might be losing money, one out of five might be winners.
However, you cannot see that without an exclusive MT4 app because all trades are on the same account.
Above is the example of many trading robots monitored on the MT4 account.
Such monitoring can be done using MyMT4Book Analyzer.
MyMT4Book groups all trades on the account by unique magic numbers and show strategy stats information for each of them.
Every EA uses its unique magic number (it is like strategy ID to identify trades). Using magic numbers, MyMT4Book can group those trades and calculate various stats like max drawdown, pips gained, win ratio, return/drawdown, profit factor, etc.
No matter if you are a beginner in Algotrading or an experienced robot trader, the Forex Robot Factory and this tutorial will get you going for sure. And if you want to learn more about trading strategy creation and robot trading in general, then check out video course from Forex Robot Academy.
Remember, it’s a long game. Survivors are the winners.
Don’t start Algotrading if you are not willing to stick around for several years.
I hope this tutorial was helpful. Share your comments below.
How many automated trading strategies are you running at the moment?