The optimization trap

Making more tests with the optimization process of my last EA i can conclude that for 2010 the EMA cross most profitable is 8 with 173 for short positions.

I found that with bigger values in Take Profits and Trial Stops the expert can get more profits like for example:

2717.52             578.42                          StopLoss=550      TakeProfit=6050      Tral_Stop=1750
profit                   drawdown $                  stop loss                take profit                    start trailing at

This means that my EA using the cross of the 8 EMA and the 173 EMA taking only short position made from 2010-01-01 to 2010-08-30 ( 8 months ) 2717.52 dollars with an initial deposit of 500 dollars. The 2717 is pure profit, the initial 500 are also there, so the trader using this system from the beginning of the year haves now a total of 3217 USD.

This last results are not the closer to the truth i can get, those results were just one of the best passes of the optimizer using control points. I am loading now this variables to the strategy tester and the results are even a little better:


The details

The proof of fire will be to test this in year 2009, i know that the classic 21 and 200 cross failed at 2009.

This is the optimization trap, the values picked was for that period of time and simply don’t work in others when conditions are different.
2010 was a big downtrend almost all the year:

The problem with a simple crossing moving averages expert is that it is to simple, it don’t check how are the conditions of the overall market, i will probably try to use more than one time frame to make something better. For example if trend is down in a h4 or daily chart use only short strategies in the 15 min charts and vise verse.

I am not ready yet.

Tags: , , , ,

Robot Optimization

Optimization of expert advisors will help me find the right parameters for different variables of the program in a period of time. It is better to use the 20 ema crossing the 200 ema or the 30 ema crossing the 193? all this kind of questions can be replied with the optimization process.

I will use control points instead of every tick so the process will be faster, we will use Expert Advisor 9 for optimization. I will run the optimizator with data of the current year, starting january 1 and ending july 31.

The 2 moving averages for the cross will be optimized, the take profits variable, the stop loss variable and the trailing stop will all be optimized as well. the mql build in optimizer will combine all this and display a report.

There is no need to use the same values for short and long trades, what it works good for long it don’t necessarily haves to work for short trades so i made 2 optimizations runs and here are the results:

Long Optimization Reports

Short Optimization Reports

It looks that the optimizer found great results for short trades, the draw down is of 20% and the expected payoff is high. This is what we look in an expert advisor, big payoffs and small drawdowns.

With this new optimized values:

StopLoss=250     TakeProfit=1850     Period_MA_1=9     Period_MA_2=171     Tral_Stop=750

i make a new expert advisor optimized for short sales, when i run it in the strategy tester using the most precise data now we get this curve from january 1st 2010 to today:

Details

Tags: , , , , , , ,

MACD Expert advisor tests

The MQL community page ( http://www.mql4.com/ ) is a great source of information and it provides me articles and source code. I can use the expert advisors made by other programmers and test them up, make modifications to them, use parts of their code, etc.

To start with this lets try a classic expert advisor that use the macd histogram and a signal line, this strategy was not something i use to trade on the days of manual trading but what i like from this expert is the way it is coded, a lot less code than what i was using to make expert advisors from the mql book.

Here is the article page: http://articles.mql4.com/84

The short and long entries are defined with the following:

The expert don’t have a stop loss, exit is executed when:

  • Long exit – by execution of the take profit limit, by execution of the trailing stop or when MACD crosses its Signal Line (MACD is above zero, goes downwards and is crossed by the Signal Line going upwards).
  • Short exit – by execution of the take profit limit, by execution of the trailing stop or when MACD crosses its Signal Line (MACD is below zero, goes upwards and is crossed by the Signal Line going downwards).

I have the historical test of 2010 for euro against dollar, 15 min chart in here: http://fforex.me/robots/macd/

As expected the expert didn’t had a great year but the lack of stop loss also have some very big losses, for example in january 2010 i can see a loss of -197.38 in a single trade. this goes totally against my tolerance, it is a very big loss for my trading style.

So i tried a new version that can also insert a stop loss of 30 into the trade, with this we will not have those big losses but we are also limiting the expert, remember that less risk can also mean less profit sometimes, this is what is happening in this case:

MACD expert with stop loss of 30

I like how it is coded as it is more compact than the expert sample of the book , i am not really expecting a profit from it, also i have to test all the experts i can found for free, it will help me understand more about the mql programming language.

Tags: , , , , ,

Strategy tester new results

The best i had until now was the expert advisor that uses the 21 and the 200 EMA cross with a 20 pips of stop loss and 30 of take profit (expert 5) and the expert where the same entry criteria was used but with a trailing stop moving in the direction of the trade after an amplitude of 40 pips is given (expert 7).

Now is time to test this 2 with the new historical consistent data:

Expert 8

and

Expert 9

The expert advisor code is the same as 5 and 7, i just want to difference the test results but they are actually the same code.

We can see that the earnings are less than with the original trades but that is of course ok if the test can be trusted.

Tags: , , , , ,

Strategy Tester Quality

I was checking the results of the strategy tester for my last experts advisors and i found that the quality of the results wasn’t something to be trusted.

Lets check some examples of out last expert advisor, Expert 7, check this results report from january 2010:

http://fforex.me/wp-content/content/experts/ea7/eur-usd/ea7_january_2010.htm

Focus in this 2 results numbers:

Modelling quality: 81.53%
Mismatched charts errors: 49

I was checking in the internet and i found that a 90% quality is solid for a historical test, on our case we have a 81.53% of quality, is not that bad really BUT lets go ahead and check some other results, for example same expert advisor in february:

http://fforex.me/wp-content/content/experts/ea7/eur-usd/ea7_feb_2010.htm

Modelling quality: n/a
Mismatched charts errors: 11006

The erros in the charts are so much (11006) that they are marked in red and also the model quality cannot be displayed. This means this results cannot be trusted at all.

Similar problems are everywhere:

http://fforex.me/wp-content/content/experts/ea7/eur-usd/ea7_march_2010.htm

http://fforex.me/wp-content/content/experts/ea7/eur-usd/ea7_april_2010.htm

A solution was needed for this problem before going further with any strategy, results haves to be trust able.  As a first approach i downloaded and synchronized the history data from meta quotes that came with meta trader, the results were even worst, huge gaps of missing data, i even found a gap of an entire month from may 7 to june 8 2010.

It was not easy, toke me a few days of research but i am now working with data from http://www.fxdd.com/, they provide free data for meta trader, with this historical data my tests are 90% quality and no mismatched chart errors are present at any tested period.

My next step is to test the 2 most profitable expert advisors i did until now using the new historical data from FXDD.

Tags: , ,

55 EMA crossing 200 EMA

We had some decent results with the last version of the expert, 21 – 200 EMA cross with 20 pips of SL and 30 of TP, 15 min chart. there is another important cross that happens a little later and i think it can be important.

In the image below the EA is getting in the market to the long side after the 55 ema cross the 200.

Robot Page

As we can see from the historical test it is clear that this edge ended up 7 first months of the year with earnings but a lot less than the  EA5.

in conclusion, the 21 – 200 cross is a better edge than the 55 – 200.

Tags: , , , ,

Emas cross 21 – 200 TP modification.

In prior versions of the emas cross robot we were using a 20 pips of stop loss and a 20 pips to take profits as well.

lets now make a new version changing the TP variable from 20 to 30, this way we risk 20 pips on each trade (same as we were doing before) but we increase our profit potential to 30.

as a disadvantage we have that in a certain trade the market can get the 20 pips but maybe can’t do it with the 30, so it will reverse and end with a loss. the only way to know it is testing the strategy.

here the results of the first 7 months of 2010:

Emas Cross 21 – 200 with a TP of 30 pips

As we can see this is the best operator we have until now working in a 24 hours environment in the euro dollar market.

Tags: , , , , , , ,

24 hours 21 – 200 emas cross july test

as expected with the robot trading in the american session only, the 24 hour version of the 200 ema crossing the 21 ema or vise versa end July with losses but smaller ones than the american robot.

EA 4 July 2010

Even with that small loss the best performance for now is still made by this robot:

EA4 Robot

Tags: ,

July 2010 Results

The best we have for now regarding to Experts advisors is the Emas Cross 21 – 200, with no loss in the last 6 months.
Now that july had ended i can test the robot on that month, the results are not good as expected, july is the first month of losses for the EA:

EA 3 July performance

Tags: ,

Experts Advisors and historial tests

To test a strategy we have the strategy tester that came with the meta trader program. on it we can see how the robot performs in past months, days, etc.
We are interested on monthly tests to start, our experts advisors are for the 15 min chart.

We had been working in real time with this robot but the results are to slow to take conclusions and are very limited to human factors, sometimes i want to try something else, some others i don’t even trade or wake up at the right times.

The strategy tester runs on a perfect world, a world where there are no errors,  where computers are always on and perfectly running. We know reality is a little harder but i think the strategy tester is the best way to know if an expert advisor will work or not in the real world of trading.

11 – 31 Moving Averages Difference for Trend Development Test results 2010:

January 2010.

Details January

Earnings:  -111.21

February 2010.

Details February
Earnings:  -104.54

March 2010.

March Details
Earnings:  -242.67

April 2010.

April Details
Earnings:  -150.48

May 2010.

May Details
Earnings:  168.92

June 2010.

June Details
Earnings:  113.49

So in 6 months, this robot made:
January -111.21
February -104.54
March -242.67
April -150.48
May 168.92
June 113.49
————————-

-326.49

The strategy will loose money in the long term if we take what the strategy can do in the last 6 months. It is interesting to see how the robot made better in the last 2 months (may and june) while the first 4 months of the year were all losses.
The strategy haves to be tweaked, remember this was just a test, this wasn’t even my strategy.

Remember here the EA was running 24 hours, i am going to tweak this robot to trade in the American Session only as it is more realistic. I can’t afford computers turned on 24/7 for now.

After the time test i will change criteria of the expert advisor so it can trade other signals.

Tags: , , ,