Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
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

Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-01-2006, 01:12 AM
Eaglehawk's Avatar
Senior Member
 
Join Date: Jun 2006
Posts: 141
Eaglehawk is on a distinguished road
Exclamation problems calling variables from functions

I'm builing an ea I can use over and over to make new ea from a standard format.

When I was recently inputting a holiday safety feature for interbankfx i created long ago, I decided to experiment a little with using functions.

Now, no matter what i do when i try to call two variables, (DayOff, and DayOffClose), from two functions i made, my opening logics compiles out, "variable not defined".

This leads me to believe it isn't returning the order integer in the closing logics either.


What am i doing wrong?
__________________
"One's ability to accomplish his or her goals is limited only by the ingenuity of how one uses what he or she already knows."- Eaglehawk
REMEMBER,
"Genius is nothing but a greater aptitude for patience." –Benjamin Franklin

____________________________________

Have a simple ea you just can't figure out how to code??? Odds are you can make it here. Just remember to push complete when you're done, NOT SAVE!!!

http://sufx.core.t3-ism.net/ExpertAdvisorBuilder

Last edited by Eaglehawk; 11-01-2006 at 01:24 AM.
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!
  #2 (permalink)  
Old 11-01-2006, 01:19 AM
Senior Member
 
Join Date: Feb 2006
Location: New Zealand
Posts: 249
Craig is on a distinguished road
//+------------------------------------------------------------------+
//| Entry logics |
//+------------------------------------------------------------------+
{
HolidayAbandonTest();
HolidayTest();
}
if ((UseDayOff) && DayOff == False && DayOffClose == False)
//put in your entry logics between theese brackets
{

}

The variables DayOff and DayOffClose are not defined in the start function.

int goodfriday(gmonth, gday)
{
double cycledays = 29.5306;//approxamation of how long it takes the moon to return to a full moon
int month = 11;//last full moon was november 2006


You are going to need types for gmonth and gday (e.g. int).
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!
  #3 (permalink)  
Old 11-01-2006, 01:23 AM
Eaglehawk's Avatar
Senior Member
 
Join Date: Jun 2006
Posts: 141
Eaglehawk is on a distinguished road
Quote:
Originally Posted by Craig
//+------------------------------------------------------------------+
//| Entry logics |
//+------------------------------------------------------------------+
{
HolidayAbandonTest();
HolidayTest();
}
if ((UseDayOff) && DayOff == False && DayOffClose == False)
//put in your entry logics between theese brackets
{

}

The variables DayOff and DayOffClose are not defined in the start function.

int goodfriday(gmonth, gday)
{
double cycledays = 29.5306;//approxamation of how long it takes the moon to return to a full moon
int month = 11;//last full moon was november 2006


You are going to need types for gmonth and gday (e.g. int).
that just gives me more errors

Compiling 'Starter EA.mq4'...

'DayOff' - variable not defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (159, 26)

'DayOffClose' - variable not defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (159, 45)

'gmonth' - variable already defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (327, 11)

'gday' - variable already defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (328, 11)

'gmonth' - variable not defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (400, 16)

'gday' - variable not defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (400, 24)

'gmonth' - variable not defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (419, 22)

'gday' - variable not defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (419, 42)

'gday' - variable not defined C:\Documents and Settings\Tricia\Desktop\Currency Study\John's Metatrader 4\experts\Starter EA.mq4 (419, 63)

9 error(s), 0 warning(s)
Attached Files
File Type: mq4 Starter EA.mq4 (17.8 KB, 22 views)
__________________
"One's ability to accomplish his or her goals is limited only by the ingenuity of how one uses what he or she already knows."- Eaglehawk
REMEMBER,
"Genius is nothing but a greater aptitude for patience." –Benjamin Franklin

____________________________________

Have a simple ea you just can't figure out how to code??? Odds are you can make it here. Just remember to push complete when you're done, NOT SAVE!!!

http://sufx.core.t3-ism.net/ExpertAdvisorBuilder
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!
  #4 (permalink)  
Old 11-01-2006, 02:10 AM
Senior Member
 
Join Date: Feb 2006
Location: New Zealand
Posts: 249
Craig is on a distinguished road
Variable not defined means the variable is not defined at global or function level (as per my first reply) Variable already defined means you have defined the variable twice.

e.g.

int goodfriday(int gmonth, int gday)
{
double cycledays = 29.5306;//approxamation of how long it takes the moon to return to a full moon
int month = 11;//last full moon was november 2006
double day = 5;//last full moon was november 5, 2006
bool FullMoon = False;//self-explanatory
int gmonth = 0;//month good friday occurs in
int gday = 0;//da

With all due repect, you really need to go and get a better idea of how variables and functions work (e.g. http://docs.mql4.com/basis/variables & http://docs.mql4.com/basis/functions) because if you can't work out what is going on with these basic errors you don't stand a chance of working out more complex logical errors. Reading a book on the C programming languge won't hurt either (http://www.imada.sdu.dk/~svalle/cour...2005/mirror/c/)
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!
  #5 (permalink)  
Old 11-01-2006, 02:34 AM
Senior Member
 
Join Date: Aug 2006
Posts: 104
tururo is on a distinguished road
Fixed compile errors

Fixed the compile errors, didn't have time to check the logic.
Attached Files
File Type: mq4 Starter EA.mq4 (17.8 KB, 16 views)
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!
  #6 (permalink)  
Old 11-01-2006, 02:35 AM
Eaglehawk's Avatar
Senior Member
 
Join Date: Jun 2006
Posts: 141
Eaglehawk is on a distinguished road
Quote:
Originally Posted by Craig
Variable not defined means the variable is not defined at global or function level (as per my first reply) Variable already defined means you have defined the variable twice.

e.g.

int goodfriday(int gmonth, int gday)
{
double cycledays = 29.5306;//approxamation of how long it takes the moon to return to a full moon
int month = 11;//last full moon was november 2006
double day = 5;//last full moon was november 5, 2006
bool FullMoon = False;//self-explanatory
int gmonth = 0;//month good friday occurs in
int gday = 0;//da

With all due repect, you really need to go and get a better idea of how variables and functions work (e.g. http://docs.mql4.com/basis/variables & http://docs.mql4.com/basis/functions) because if you can't work out what is going on with these basic errors you don't stand a chance of working out more complex logical errors. Reading a book on the C programming languge won't hurt either (http://www.imada.sdu.dk/~svalle/courses/dm14-2005/mirror/c/)

With all do respect, that is exactly what i have done, i can tell you haven't payed attention to the small change in the code you suggested. i had already tried to do that several times before. I have a larger understanding of what i'm doing than you give me credit. and i research what i do, i've looked at both of those before, and i have skimmed through several c+ books. refrence alone can not gain skill in a single area of coding, or in coding as a whole, no refrence i have observed has givin an example of EVERY possible use for a tool mentioned, to do so would take extra time, and make their books and refrences much longer. if i am troubled by some errors with a compiler, i generally experiment obvious answers to solve them, i'm not someone who posts questions on this forem simply for every problem i am confronted with.
__________________
"One's ability to accomplish his or her goals is limited only by the ingenuity of how one uses what he or she already knows."- Eaglehawk
REMEMBER,
"Genius is nothing but a greater aptitude for patience." –Benjamin Franklin

____________________________________

Have a simple ea you just can't figure out how to code??? Odds are you can make it here. Just remember to push complete when you're done, NOT SAVE!!!

http://sufx.core.t3-ism.net/ExpertAdvisorBuilder

Last edited by Eaglehawk; 11-01-2006 at 02:45 AM.
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!
  #7 (permalink)  
Old 11-01-2006, 02:41 AM
Eaglehawk's Avatar
Senior Member
 
Join Date: Jun 2006
Posts: 141
Eaglehawk is on a distinguished road
Quote:
Originally Posted by tururo
Fixed the compile errors, didn't have time to check the logic.
thank you tururo, i can deal with the logics now that i know what was wrong with the errors.
__________________
"One's ability to accomplish his or her goals is limited only by the ingenuity of how one uses what he or she already knows."- Eaglehawk
REMEMBER,
"Genius is nothing but a greater aptitude for patience." –Benjamin Franklin

____________________________________

Have a simple ea you just can't figure out how to code??? Odds are you can make it here. Just remember to push complete when you're done, NOT SAVE!!!

http://sufx.core.t3-ism.net/ExpertAdvisorBuilder
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!
  #8 (permalink)  
Old 11-01-2006, 03:19 AM
Senior Member
 
Join Date: Feb 2006
Location: New Zealand
Posts: 249
Craig is on a distinguished road
Thought you might say somthing like that, your code changes suggested you do not know what you are doing, all I am suggesting is you might benefit from learning some more programming fundimentals, I forward this as a helpful suggestion from somebody who has been down the same road, not as a put-down.

You are correct in that good programming skills come from practical experence, but you really need to understand (for example) how to declare a function properly before you start coding and you also need to understand the concept of variable scoping, this is gone over in the MQL documentation I have referenced, which you have so obvously NOT read.

I could have also fixed your errors for you, but what good does that do? you still have no idea why it was broken!! If you can't take some gentle proding in the direction of the facts, your not going to get very far...in fact why am I bothering even writing this because your only going to ignore it anyway...or tell me I'm full of shit...losing interest zzzzzzzzzz
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!
  #9 (permalink)  
Old 11-01-2006, 03:44 AM
Mazoem's Avatar
Member
 
Join Date: Dec 2005
Location: Tulsa, OK USA
Posts: 59
Mazoem is on a distinguished road
Quote:
Originally Posted by Craig
Thought you might say somthing like that, your code changes suggested you do not know what you are doing, all I am suggesting is you might benefit from learning some more programming fundimentals, I forward this as a helpful suggestion from somebody who has been down the same road, not as a put-down.

You are correct in that good programming skills come from practical experence, but you really need to understand (for example) how to declare a function properly before you start coding and you also need to understand the concept of variable scoping, this is gone over in the MQL documentation I have referenced, which you have so obvously NOT read.

I could have also fixed your errors for you, but what good does that do? you still have no idea why it was broken!! If you can't take some gentle proding in the direction of the facts, your not going to get very far...in fact why am I bothering even writing this because your only going to ignore it anyway...or tell me I'm full of shit...losing interest zzzzzzzzzz
Wow... 5 post's and you are already being a jerk to someone like Eaglehawk? He's got 150+ posts here, and if you read more than 3 of them you would know how far out of line you are. Grow up.
__________________
"Only those who dare to fail greatly can ever achieve greatly."

Last edited by Mazoem; 11-01-2006 at 03:51 AM.
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!
  #10 (permalink)  
Old 11-01-2006, 04:37 AM
Senior Member
 
Join Date: Feb 2006
Location: New Zealand
Posts: 249
Craig is on a distinguished road
Does the fact that he has posted here more than me mean that I have to avoid the truth? I have looked back though this posts, I'm not too sure what part of his posting is supposed to engender respect. He is trying to write EA's, fair enough, I just think he should have a better grasp of what he is doing from a coding point of view, this suggestion was made to help him, it's going to help him get where he wants to be is it not?

I offered help, he is the one that did his nut when I suggested some research. I don't see what is immature on my part. Quite the opposite in fact.
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!
Closed Thread

Bookmarks


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
HMA - Calling All Programmers!! secxces Indicators - Metatrader 4 70 05-24-2009 11:45 AM
Lesson 8 - Variables in MQL4 codersguru Lessons 18 05-07-2009 06:13 PM
How to enter external variables? icepeak Metatrader 4 6 12-05-2006 05:25 PM
MT 3 user defined variables! TallP Metatrader 3 0 07-12-2006 08:09 PM


All times are GMT. The time now is 07:29 PM.



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