Posts Tagged ‘MetaTrader expert advisors’

Reversing Forex Strategies and Expert Advisors

Wednesday, July 23rd, 2008

Many traders encountered strategies and expert advisors that produce highly stable loss as the result of their trading. The majority of those traders at least once considered a possibility of reversing the strategy/EA by switching the buy and sell orders, hoping to reverse the strategy’s results. In almost every case this tactic would fail and the results of the reversed expert advisor would be no better than before. The problem is that not every Forex strategy or expert advisor can be successfully reversed. The Forex strategy should be symmetrical to be reversed right.

Reversible (or symmetrical) Forex strategy is the strategy where:

  1. Buy and sell orders don’t depend on each other.
  2. Entry points don’t depend on the previous positions’ profits.
  3. Order closing doesn’t depend on price (no stop-loss or take-profit).
  4. The strategy itself shouldn’t endorse only long or only short orders.

Reversible strategies exit positions depending on the time — usually it’s either a certain amount of the new bars closed or a new signal generated. In theory stop-loss shouldn’t be used at all, but in practice if it’s used only for securing position from the extreme price movements and is rarely triggered it won’t hurt the reversibility (the same can be applied to the take-profit parameter too).

Example 1. Simple reversible EA — it opens a new position after opening of the new bar, closing the previous position simultaneously. To determine the direction of the position the expert advisor checks the Close-Open difference of the previous bar and if it’s positive it goes long, if negative — goes short. It’s rather stupid strategy but it’s only an example. We won’t take into account the broker’s spread in this example. This EA first went 2 times long and then 3 times short with the results being: +10, -40, +5, +5, -20. The total loss of this expert advisor would be -40 pips. As we see this is a reversible EA (it complies with each of the four conditions for reversibility), so let’s try reversing it. Now we’ll go long on negative Close-Open difference of the previous bar and short on positive. On the same bars as above we’d get: -10, +40, -5, -5, +20. That’s exactly +40 pips — a reversed strategy produced a reversed result (with spread wider than 0 it would be another result, but for the sake of the example spread is ignored here).

If you back-test or forward-test a reversible strategy and get a negative profit over months, you can turn it to positive simply by reversing this strategy. But unfortunately it’s not that easy. Often the reversible strategies will produce almost zero profit/loss over a long period of time — in this case reversing is useless. There is a strict and quite obvious rule to find out if the reversing would be justified. If the loss in pips for the period is significantly greater than the spread multiplied by the number of trades made for the period, then this strategy is worth reversing; in other cases you’ll still get your margin eaten by the broker’s spread.

Example 2. The strategy from the first example produced 40 pips loss with 5 trades. If it’s EUR/USD pair which usually has 2 pips spread, then you get only 10 pips (5×2) of loss produced by the spread. So, reversing the strategy in this case will change -40 pips result to +30 pips — definitely a good result.

Example 3. Consider a reversible strategy that produced 500 pips loss over 6 months of backtesting. The currency pair used in the test was GBP/JPY (7 pips spread) and the number of positions opened and closed during this test was 70. If we reverse this strategy and run the back-test again we’d get only 10 pips profit (500 — 7×70). Such reversing isn’t justified as the gain lies within the normal profit/loss fluctuation range.

If you try to reverse asymmetrical Forex strategy, most probably, it will produce the same result as before due to its inner mechanics. At least all lossy expert advisors that I’ve back-tested in my MetaTrader 4 tester remained lossy after reversing. That doesn’t mean that everyone should stop developing irreversible strategies and switch to symmetrical. Each of those strategy types has its own advantages and disadvantages. Just learn to distinguish one from another and use it accordingly.

6 Digit Forex Quotes and MetaTrader Expert Advisors

Wednesday, March 19th, 2008

Many Forex brokers have started to offer 6 digit Forex quotes to via the MetaTrader 4 terminal recently. It has a lot of benefits for the scalping traders and opens up many new trading possibilities for others. But there seems to be a problem with almost all expert advisors that are applied to the MetaTrader 4 platform, which uses 6 digit Forex quotes instead of the more conventional 5 digit format. As the most expert advisors use the "Point" variable for pips to denominate stop-loss and take-profit, there are two major problems with the 6 digit quotes. First, both stop-loss and take-profit values have very strong chances to come to close to the current pair’s price and MT4 will generate an Error 130, if they are to close. Second, the whole strategy embedded into the given EA will stop working properly because all the profits and losses will probably be divided by 10.

Let’s look at the following example. With a 5 digit quote EUR/USD rate is 1.5703 and one Point in MetaTrader 4 is 0.0001 — a conventional pip for EUR/USD pair. Our expert advisor buys EUR/USD, setting stop-loss at 20 pips — 1.5683, and take profit at 40 pips — 1.5743. Everything goes fine and we win 40 pips when the rate reaches 1.5743. But for a 6 digit quote things are completely different. E.g. the rate above might have been 1.57032 and one Point in your MT4 would have been 0.00001 — ten times less than the conventional pip for EUR/USD. The same expert advisor would have set the stop-loss at 1.57012 and take-profit at 1.57072. Not only 99% of the brokers wouldn’t allow such a close stop-loss and take-profit setting, but if allowed this position wouldn’t be very rational and of course it wouldn’t be according to the initial strategy rules.

So how to correct this problem without completely rewriting the expert advisor and, of course, without changing a broker (to one with the 5 digit quotes)? First, I’d like to tell you that all MetaTrader expert advisors that are featured on my site have been already modified to work with both 5 and 6 digit quotes. Second, here is the way to make any EA to work properly with 6 digit quotes:

  1. Open the .mq4 of the expert advisor that you want to change in MQL Editor.
  2. Add a new global variable declaration (it should be in the beginning of the code, along with other variable declarations):
    double Poin;
  3. Add the following code to the init() function of the EA. This function is usually present in all EAs (it contains various initialization routines), but if it’s not there, create it and include this code:
    //Checking for unconventional Point digits number
    if (Point == 0.00001) Poin = 0.0001; //6 digits
    else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)
    else Poin = Point; //Normal
  4. Replace all further occurrences of "Point„ in the code with “Poin„ (except those in the init() function). This will change the system MT4 variable “Point„ to our declared variable “Poin", which now contains the standard 5 digit pip value.
  5. That’s all. Compile it and you are ready to run it on the 6 digit quotes in MetaTrader. Of course, it will still work with standard 5 digit quotes too.

MetaTrader 4 Expert Advisors and Indicators

Monday, December 3rd, 2007

I’ve reworked the MetaTrader expert advisors page gradually, removing more than a half of the expert adviors that were poorly tested earlier and aren’t profitable according to my new test results. I’ve been testing all the expert advisors on the period from 11/19/2006 to 11/19/2007 and EAs that were successful on this period I also tested on a 11/19/2004 to 11/19/2007 period to confirm their results stability. All backtests had 90% testing quality. The descriptions of the expert advisors now include the test results and my own notices reg their use.

Another change to the site - I’ve added MetaTrader indicators page which will contain free MT4 indicators available for download. Right now it holds only 5 indicators, but more will be added soon. All indicators have their own description.

Metatrader Expert Advisors - User’s Tutorial

Wednesday, July 11th, 2007

Using Metatrader expert advisors is simple, but sometimes people get confused with it and after downloading a file with the expert advisor a user might get stuck with it without knowing what to do next. This a simple tutorial on how to attach an expert advisor to Metatrader 4 char and activate it.

1. Download your MT4 expert advisor or copy it and save it to your Metatrader’s ‘experts’ folder:

Saving Metatrader 4 Expert Advisor
2. Double click it with your mouse and it will be opened in MQL editor (this editor comes with MT4). There will be a button ‘Compile’ at the center top of the window. Click it and your expert advisor will be compiled and ready to use. There might be some errors or warnings during the compilation, but in most cases there shouldn’t be any. You can try and fix those errors, but it takes time and some programming skills, usually.

Compiling Metatrader 4 Expert Advisor
3. Now, all you need to do is add your expert advisor to the preferred chart and activate it. You can also change some input parameters for the advisor in the Inputs tab:

Adding Metatrader 4 Expert AdvisorThat’s it! Now you can enjoy your expert advisor - its signals or its trading (if it is designed to perform trading). Good luck with them!



InstaForex Broker