The hedge trade

My current trading strategies are based on indicators, specially i did a lot with crossing moving averages.  On my last posts i concluded that a simple moving average cross is to simple to be a reliable signal so i tried to use the upper timeframe to get the trend and trade with it. Results were similar, the cross of moving averages works some times as some other don’t, a clear example is the profitability of year 2010 while in 2009 tests results end with big losses.

The market is so chaotic that it is almost impossible for a trader using a single indicator to predict market behavior. i checked my old notes and i found something that was very interesting and surprising when i saw it and that i think it will drive my approach starting now until i can prove that the strategy don’t work as i did with the moving averages ones.

In my notes i found myself trading the euro using the Sp-500 stocks index, this was in the Euro crisis we had this year. At that time i found that this 2 instruments were moving in the same manner, if the sp-500 started to rally the euro was following it just a few seconds or minutes after.

Correlations are common in the financial world and i am seeing them now as a vulnerability the market haves, it is easy to calculate correlation in real time using mql.

The following 2 articles are what i am studying now, http://codebase.mql4.com/6601 and http://articles.mql4.com/445

Using the second article i was able to test the hedging strategy using the mql tester and i am now using article 1 expert advisor(myHedge) to test hedging in demo live to find a profitable hedging strategy.

There is a lot to do, read and test, i will be adding results to the diary soon.

Tags: , , , , ,

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: , , , , , , ,

More historical tests

demonstrates that the EA 9 ( http://fforex.me/robots/emas-cross-21-200-trailing-stop-corrected-tests/ ) had a really bad year during 2009 ending the year with losses.

a loss for an entire year means that the expert will not be profitable, further actions should be taken, i am now working on optimization of this expert. see next post.

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: , ,

EMAs Cross Robotic Trading

This is an edge i was always trying to use when i was trading manually.  Without the discipline problems this robot will just execute a trade when the 21 EMA Cross the 200 EMA up or down side.
At the same time the EA opens a SL and a TP of 20 pips and it stays in the market until one of the 2 gets executed.

Emas Cross 21 – 200

Here is a nice image of what the robot can do in action, simple but effective:

Lets see how he can do it in the strategy tester, for the US session, euro-dollar market:

January 35.84
February 50.99
March 78.93
April 17.14
May 92.30
June 95.00

——————————
370.2

this is great, even if it doesn’t look as much earnings this program made profits every month, it never had a month with losses.
Risk seems small too i will have to learn how to calculate risk.
I will make some tweaks to this program, i will also test it 24 hours. i am seeing in the internet that there is the possibility to have dedicated windows hosting for mql to don’t rely on my own internet connection and local problems so the 24 hours trading is still a possibility.

I am glad to see some light at the end of the tunnel and have something that can really work, i think i am in the right path.

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: , , ,

First Auto trade

The first robot i will be testing is the one i call “11 – 31 Moving Averages Difference”, it is a very basic expert advisor for mql but i will help me to start to see how all this work.

Please check the trades i am making with this robot and the variables used in here:  http://fforex.me/robots/11-31-moving-averages-difference/

Let’s see how it works with some images, here the robot makes an entry in the short side.
Please note that at this time that the difference between the 11 and the 31 moving averages is equal or more than 18 pips. This gives the robot criteria to open a short order.
The robot simple obey and open the trade:

Here you can see the market trading very close to the TP line of 20 pips but without hitting it:

The market bounce up, robot was very close to profits but now we are facing losses. The robot idea is no intervention so i am just spectating totally outside:

SL is finally hitted, the trade ends with -20.90 pips.

Even with a loss, i learned a lot from this trade and i liked this EA. It was so close to profits that i am sure this robot can win sometimes, i like the criteria the robot haves and it is a great start to make bigger things.

Remember to check how the robot is doing here:

http://fforex.me/robots/11-31-moving-averages-difference/

Tags: , , , , , ,