forex software

Create and Test Forex Strategies

forex software

eas-guide:strategies-and-expert-advisors

Expert Advisors

Manual Trading

MetaTrader

MetaTrader is the most popular trading platform in the world. Most regulated brokers provide it free of charge. MetaTrader is developed by a company called MetaQuotes. Currently, MetaTrader 4 is the preferred trading platform among traders. There is also a newer version - MetaTrader 5. MetaTrader 5 is the latest version however, it is not as popular.


The main purposes of a trading platform is to deliver data from the broker to your screen and to allow you to trade. MetaTrader allows you to trade manually as well as automatically.

In the image below, you can see a price chart of the EURUSD market. You can trade manually - buy and sell on the market. You can also see the current (latest) price on the far right of the chart. The price constantly changes and it is not always easy to decide whether you should buy or sell and what point in time you should execute your trade. Of course, you want to trade in the correct direction because you want to make a profit.

Indicators

To allow you to make a better decision MetaTrader has options to add indicators on the chart. Indicators are shown as lines or bars that will run along the price chart. Indicators are mathematically based on price history and other market parameters.

You can add an indicator to the chart very easily. For our example, we will use one of the most popular indicators - MACD (“Moving Average Convergence Divergence”). You can just drag and drop the indicator from the MetaTrader Navigator box onto the chart. (if you don't see the navigator go to View > Navigator to enable it)

Once we add the indicator, a window displaying the Options appears. Since indicators are based on mathematical formulas we can choose the Inputs tab and choose values for some of the variables in the mathematical formula of the indicator. By changing the variables, you can change how the indicator is drawn out on the chart.

As soon as you drop the indicator onto the chart you will see red lines appear on the chart. You will also notice bars appear below the chart. (If the indicator opens a dialogue window, just press OK.)

The grey bars here show the MACD line and the red line is called a “signal line”. When the market changes this indicator's line changes and the bars also change.

You can use these changes as they appear as signals to select inwhich direction to open your trade - long (buy) or short (sell) when to open and when to close a position. These signals define your trading strategy. When to buy, when to sell and in what direction.

One potential signal could be, that if you see the grey MACD bars go above the red line this might be a good signal for entering in a long position. However, how do we know if this is a good idea or not? We can test it on a demo account but it will take a significant amount of time.

Automatic Trading

Indicators are great for guiding us in manual trading. However, if we want to automate trading and leave MetaTrader to trade on its own while we're busy elsewhere, we cannot do that by simply using indicators. MetaTrader Indicators contain no trading logic. This is where our Expert Advisors go to work.

Expert Advisors

If you are going to trade automatically, you need a trading strategy. More specifically in automated trading, your trading strategy is the rules of when to open a position and when to close a position and in which direction.

Trading strategies are just the rules. Expert Advisors are the implementation of the rules in code that MetaTrader can understand and execute in MQL (MetaQuotes Language) code. This is why with our software you can export your trading strategy as an Expert Advisor.

MQL is not easy to code with. In fact it is more difficult than normal programming because aside from programming, you need to have a clear understanding of how MetaTrader works internally.

Writing Expert Advisors

To program Experts, you need to know how MetaTrader works but this is just the start. You need additional knowledge to create a potentially profitable Expert Advisor. You need to know how the market works and how the indicators work.

After you have completed the programming portion, you will want to test your Expert Advisor. If you are not happy with the results you need go back, change the code and test it again until you are happy with the EA's performance on historical data. This is the most tedious part and many people get stuck at this point because it takes a huge amount of time.

Backtesting in MetaTrader

Backtesting is the process of executing your trading strategy (or your Expert Advisor) on the historical data from your broker. Only then can you can see how it would have performed if it was trading on this market during this time.

To backtest your strategy you can use MetaTrader's Strategy Tester. Because MetaTrader downloads historical data from the broker you can use the data and the Strategy Tester to test your Expert Advisors.

However, there is a better way.

Automatically Creating Expert Adivsors

There are tools that allow you to generate Expert Advisors without coding. ANd this is where we are able to really assist you. Instead of spending countless hours on coding, testing, changing and optimizing your Expert Advisors we can offer you a tool that does all of that for you.

Expert Advisor Studio is designed to help you analyze, generate and test strategies. It also lets you easily export those strategies as Expert Advisors so you can autotrade with them in MetaTrader.

Strategy Overview

In Expert Advisor Studio you can specify the strategy logic manually too.

In the image above you can see EA Studio's Strategy Editor. In the middle column, there are some coloured boxes. The box at the top is the Strategy Properties. If you click on it you can set the entry lots for the strategy as well as the protections and profit levels, known as your Stop Loss and Take Profit (see below).

The boxes below the Strategy Properties box are the Entry Rules. Each entry rule is based on an indicator's behaviour. For example in our case when Force Index changes its direction to downward we will enter a long position.

If you click on an Entry Rule box you can see more data and specify different logical conditions for when it should act.

For the strategy to enter a position all of the Entry Rules must be met at the same moment.

Below the Entry Rules are the Exit Rules. Similar to Entry Rules if you click on an Exit Rule you can specify the logic for when to act on each indicator.

Exit Rules behave differently from Entry Rules. As soon as only one of the Exit Rules is met the strategy will exit the position.

To remove a rule use the X button on its box.

To add a rule use the Add new… boxes