Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > 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
 
LinkBack (3) Thread Tools Display Modes
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 12-27-2005, 10:18 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Wink Lesson 16 - Your First Expert Advisor (Part 4)

We have reached the edge of the moon in our way to the truth, I’m not under the impact of alcoholic poisoning (I don’t drink at all), but I’m so happy to reach the last part of explaining or first expert advisor. Yes! This is the last part of the expert advisor lesson.



I hope you enjoyed the journey discovering how to write our simple yet important expert advisor.

Let’s take the final step.
Attached Files
File Type: pdf Lesson16.pdf (40.3 KB, 1678 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!
Reply With Quote
  #2 (permalink)  
Old 12-27-2005, 11:02 PM
beerhunter's Avatar
Member
 
Join Date: Nov 2005
Posts: 43
beerhunter is on a distinguished road
Fantastic! Your work is invaluable!! Many many thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-28-2005, 04:34 AM
kamyar's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Iran
Posts: 635
kamyar is on a distinguished road
hi

i aggree with beer.your work souns greate.in my opinion it is MQL4 bible.thanks a lot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-28-2005, 08:48 PM
Junior Member
 
Join Date: Dec 2005
Posts: 2
allan.zorro is on a distinguished road
Codersguru,

You Da Man!
Thank you for posting and all your hard work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-28-2005, 09:43 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Talking You're welcome!

beerhunter, kamyar, allan.zorro,

You're welcome! I hope you've enjoyed the lessons.
__________________
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!
Reply With Quote
  #6 (permalink)  
Old 01-03-2006, 01:18 PM
Junior Member
 
Join Date: Nov 2005
Posts: 18
saslam is on a distinguished road
Thanks for the great course. It is very useful.

How can I use a custom indicator like pricechannelstop in the EA?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-08-2006, 07:13 PM
Junior Member
 
Join Date: Jan 2006
Posts: 1
El Choco is on a distinguished road
Excellent

Hi Guru,

Yep, excellent work, thanks for all this amazing help. It's going to take a few days to get to grips with all this but it's been really helpful to have your lessons.

Thanks again !

El Choco
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-31-2006, 04:58 AM
Member
 
Join Date: Nov 2005
Posts: 52
suffic369 is on a distinguished road
Dear Sir

you have decleared the two static variables inside the block of the function. then every time start function recieves a quote it will call the crossed function,and every time when start calls crossed, crossed will first initilize the two varibles to zero,so how could you compare current_direction with last_direction?

int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_dirction = 0;

if(line1>line2)current_dirction = 1; //up
if(line1<line2)current_dirction = 2; //down



if(current_dirction != last_direction) //changed
{
last_direction = current_dirction;
return (last_direction);
}
else
{
return (0);
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-31-2006, 02:28 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Static variables

Quote:
Originally Posted by suffic369
Dear Sir

you have decleared the two static variables inside the block of the function. then every time start function recieves a quote it will call the crossed function,and every time when start calls crossed, crossed will first initilize the two varibles to zero,so how could you compare current_direction with last_direction?

int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_dirction = 0;

if(line1>line2)current_dirction = 1; //up
if(line1<line2)current_dirction = 2; //down



if(current_dirction != last_direction) //changed
{
last_direction = current_dirction;
return (last_direction);
}
else
{
return (0);
}
}
suffic369,

Thanks for the question!


There are two kinds of variables in MQL4, normal variables and static variables;
The static variables are very like the normal variables with only one extra feature:

The initialization of the static variables occurs only one time.
Which means if you write a line of code like that:


static int last_direction = 0;


You mean:

If this is the first call of the program, initialize the variable to 0, else (if it's the second, third, fourth etc call) don't initialize the variable again.


But if you used a normal variable instead of static variable, every time you call your program the initialization of the variable will be occurred.
__________________
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!
Reply With Quote
  #10 (permalink)  
Old 04-19-2006, 11:29 AM
Junior Member
 
Join Date: Apr 2006
Posts: 1
Jicco is on a distinguished road
Hi, at start i want say thank you for your great job you're doing to help us to learn programming MQL4.

I've got problem. My First EA is not working correct. When MA lines getting crossed, MT try to open order but such error occurs every time:

2006.04.19 13:14:12 My_First_EA EURUSD,M1: Error opening SELL order : 4109

It is the same with Long position.

#define ERR_TRADE_NOT_ALLOWED 4109

I know it is connect with these lines of code:

if(isCrossed == 2)
{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"My EA",12345,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}


But i can't get it why this error occurs. I would be pleased if you could help me. Best Wishes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/lessons/671-lesson-16-your-first-expert-advisor-part-4-a.html
Posted By For Type Date
Vegas Wealth Builder - Part I - Page 5 This thread Refback 02-16-2008 07:26 PM
Forex Factory - View Single Post - Vegas Wealth Builder - Part I This thread Refback 08-30-2007 02:17 PM
Vegas Wealth Builder - Part I - Page 5 @ Forex Factory This thread Refback 06-28-2007 11:37 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 14 - Your First Expert Advisor (Part 2) codersguru Lessons 12 07-04-2008 09:35 AM
CCI Expert Advisor rodrigokaus Expert Advisors - Metatrader 4 10 09-29-2006 06:31 PM
Lesson 15 - Your First Expert Advisor (Part 3) codersguru Lessons 5 12-27-2005 10:00 PM
Lesson 13 - Your First Expert Advisor (Part 1) codersguru Lessons 19 12-27-2005 09:04 PM


All times are GMT. The time now is 06:34 AM.



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