Ready to build some winning trading strategies and boost your Expert Advisor portfolio?
Awesome!
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!
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.
That’s all.
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.
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.
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.
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.
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.
Useful read: You Will Not Find Forex Strategies If Your Forex EA Generator Is Set Incorrectly.
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.
I have set all the necessary settings, and now I am ready to start the EA Generator.
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.
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.
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.
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.
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.
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.
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:
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.
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 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.
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.
Pros:
Cons:
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.
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.
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.
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.
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?
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.
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.
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.
After I export all 5 trading robots, I open the Downloads folder.
I select all 5 MT4 Expert Advisor files (they have MQ4 extension) and choose Copy in the right-click menu.
To install those trading robots into my MT4 trading platform, I need to open Data Folder from the File menu.
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:
\Data Folder\MQL4\Experts\
All 5 trading robots are now in the MT4 Data Folder.
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.
Now, I need to open five EURUSD 1-hour charts.
A chart for each EA.
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.
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.
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.
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?
What is Metatrader 4? MetaTrader 4 is one of the leading platforms in the world…
In this MT4 tutorial, Rimantas explains how to download MetaTrader 4 and open Forex demo…
There you'll find video tutorials for the Equity Sentry software for MT4. (more…)
There you'll find video tutorials on how to install and use the Trader On Chart…
There you'll find video tutorials on how to install and use the Trendline Trader EA…
Installing and running multiple MT4 client terminal instances on the same machine is easier than…