Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Lessons
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-27-2005, 11:18 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 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, 2264 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 12-28-2005, 12:02 AM
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!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 12-28-2005, 05: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!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 12-28-2005, 09:48 PM
Junior Member
 
Join Date: Dec 2005
Posts: 3
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!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 12-28-2005, 10:43 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
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!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 01-03-2006, 02: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!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 01-08-2006, 08: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!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 01-31-2006, 05: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!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 01-31-2006, 03:28 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 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!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 04-19-2006, 12:29 PM
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!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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 13 - Your First Expert Advisor (Part 1) codersguru Lessons 21 02-07-2009 11:52 AM
Lesson 14 - Your First Expert Advisor (Part 2) codersguru Lessons 12 07-04-2008 10:35 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 06:20 PM.



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