Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Lessons






Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-24-2005, 05:08 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Wink Lesson 13 - Your First Expert Advisor (Part 1)

In the previous lesson we created our first indicator. Although this indicator wasn’t useful for us as trader, but it was very useful for us as programmers.

The indicators -in general- are very important for the technical analysis of the market in trying to predict the future prices.
But with the indicators we observe the chart then use our hands to sell, buy and modify our orders manually. You have to set in front of your terminal, and keep your eyes widely open.

If you get tired, want to drink a cup of tea or even take a short vacation. You have to consider one of these solutions:

You may rent someone to observe the terminal for you and calling your mobile phone every five minutes to tell you what’s going on. If this employee is an expert, he will cost you the pips you earn. And if he is novice one, he will cost you your capital.

The second solution is using a program to automate your trades.
That’s what the Expert Advisor is for.

The Expert advisor is a program wrote in MQL4 (we are studying MQL4 huh?) uses your favorite indicators and trade methods to automate your orders.
It can buy, sell and modify the orders for you. It enables you to drink a cup of tea and save the salary you gave out to your employee or the bunch of flowers you bring to your assistant wife.
.......

Why don't download the lesson and enjoy?
Attached Files
File Type: pdf Lesson13.pdf (208.7 KB, 6607 views)
File Type: mq4 My_First_EA.mq4 (5.0 KB, 4386 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 11-25-2005, 01:23 AM
Member
 
Join Date: Nov 2005
Posts: 48
barry is on a distinguished road
Ea

Hi Coders Guru,
I'm looking forward to learning all the parts of this EA. I noticed in the code:

static int last_direction = 0;
static int current_dirction = 0;

Note the missing "e" in the 2nd line. I don't know if this will matter, but I thought I'd better bring it to your attention.

This EA seems to be a EMA 8,13 crossover. It makes a loss on my eurusd H4 chart, so I would like to be able to optimise the 8 and 13. I guess by now we should be able to make them ext double variables and optimise them, so I will try to do that.

Also, how do we ask the EA to draw the 2 EMA's on the chart? I don't know why EA's don't automatically draw the indicators they use, because we will always want to see them.

Thanks again for these great lessons.

Last edited by barry; 11-25-2005 at 01:41 AM. Reason: More thoughts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 11-25-2005, 02:54 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Thanks

Quote:
Originally Posted by barry
Hi Coders Guru,
I'm looking forward to learning all the parts of this EA. I noticed in the code:

static int last_direction = 0;
static int current_dirction = 0;

Note the missing "e" in the 2nd line. I don't know if this will matter, but I thought I'd better bring it to your attention.
Thank you very much for your notice, Although it will not make problems in the code, but I'll correct that.

Quote:
This EA seems to be a EMA 8,13 crossover. It makes a loss on my eurusd H4 chart, so I would like to be able to optimise the 8 and 13. I guess by now we should be able to make them ext double variables and optimise them, so I will try to do that.
It makes profit for me (EURUSD - H4), Please tell me how many Bars in test (you will find this number in the left top of the Report).
Anyway, this EA is for educational purpose only.

Quote:
Also, how do we ask the EA to draw the 2 EMA's on the chart? I don't know why EA's don't automatically draw the indicators they use, because we will always want to see them.
Yes, it’s a bad thing that the EAs don't automatically draw the indicators they use in the live trading.
But you can see the indicator in Strategy tester by clicking Open chart button in the Strategy Tester Settings tab.

Quote:
Thanks again for these great lessons.
You're Welcome. And thanks again.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 11-26-2005, 04:04 AM
Member
 
Join Date: Nov 2005
Posts: 48
barry is on a distinguished road
Bars in Test

There were 1492 bars in my losing test. How many did you have in your profitable test?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 11-26-2005, 11:22 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Quote:
Originally Posted by barry
There were 1492 bars in my losing test. How many did you have in your profitable test?
I was have 832 bars, Please find the detailed report attached.
Attached Files
File Type: zip Report.zip (10.1 KB, 423 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 11-28-2005, 03:44 AM
Member
 
Join Date: Nov 2005
Posts: 48
barry is on a distinguished road
Results

Coders Guru,
Thanks for the report. I know the point of this is to learn to code, but I wanted to check that we get the same results, so I know I'm doing it right. In fact, we don't get the same results for the same script, but it's pretty close, and I'm guessing the difference is due to different data. I get my data from InterbankFX.
Thanks again, love the course,
Barry
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 11-28-2005, 10:55 PM
Audio's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 139
Audio is an unknown quantity at this point
ea

Quote:
Originally Posted by codersguru
I was have 832 bars, Please find the detailed report attached.
Hallo guru ,I it seems like the result of the ea here is go south ,what happen? is is becouse of differnce of the broker or I dont know how to apply it ,your look great base on what is these ea guru ? Regards audio
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 11-29-2005, 12:56 AM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow

Quote:
Originally Posted by Audio
Hallo guru ,I it seems like the result of the ea here is go south ,what happen? is is becouse of differnce of the broker or I dont know how to apply it ,your look great base on what is these ea guru ? Regards audio
Audio,

I think the differnce of the data feed (as Barry said) is the reason of the differnce of results.
For example different brokers and the different number of bars.

Anyway , This EA is for educational purpose and we can not study its behavior as a real EA.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 12-03-2005, 08:15 PM
Audio's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 139
Audio is an unknown quantity at this point
Quote:
Originally Posted by codersguru
Audio,

I think the differnce of the data feed (as Barry said) is the reason of the differnce of results.
For example different brokers and the different number of bars.

Anyway , This EA is for educational purpose and we can not study its behavior as a real EA.
ok guru but if we reverse the contain of it may be good?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 12-03-2005, 10:21 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Post What do you mean?

Quote:
Originally Posted by Audio
ok guru but if we reverse the contain of it may be good?
Audio,

What do you mean? Do you mean increasing the number of history bars? Or changing the broker?
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
lesson 13, lesson

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CCI Expert Advisor rodrigokaus Expert Advisors - Metatrader 4 26 07-20-2009 06:36 AM
Lesson 14 - Your First Expert Advisor (Part 2) codersguru Lessons 12 07-04-2008 10:35 AM
Lesson 16 - Your First Expert Advisor (Part 4) codersguru Lessons 16 10-05-2006 06:42 AM
Lesson 15 - Your First Expert Advisor (Part 3) codersguru Lessons 5 12-27-2005 11:00 PM


All times are GMT. The time now is 08:58 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.