The documentation answers your first two questions:
https://www.mql5.com/en/docs/basis/function
You should maybe get a handle on language basics before attempting your third question.
A general programming book or tutorial may be of use to you.
Hi, I'm new to programming, I have some questions, one is that I can't understand what does different returns mean, for example
return(0) , return(NULL), return(INIT_SUCCEEDED)
my second question is that how can I go from a function to another one, for example
function a ()
{
if (condition = true) go to function b (),
}
function b()
{
}
the third question is that what functions is necessary to be in our expert advisor because when I delete all the default functions and I start to write a function like below, it doesn't work and show error
thanks for your help
Your function is correct, but you have to tell it when will be called this function, that's the "event handler".
void OnStart() //<--- when the script will start { hello(); //<----- hello(); will be called. }
Then about the return :
- int hello() must return an integer (0,1,2,3,4,5,6,7 ...)
- string hello() must return a string ("one","two","three","four")
- double hello() must return a double (1.232255 etc ...)
- bool hello() must return a boolean (true/false)
- void hello() returns nothing - your case, since you're asking only for an alert()
So you should use :
int hello(a,b) { int c = a + b; return(c); } void OnStart() { Alert(hello(5,2)); // bring up an alert with 7 }
The third question is about event handler, you'll need : OnStart() (when it starts) ; OnTick() (when a new tick arrive) - for now I suppose it'll be enough.
It's newbie programming but I respect people who wants to learn.
Your function is correct, but you have to tell it when will be called this function, that's the "event handler".
Then about the return :
- int hello() must return an integer (0,1,2,3,4,5,6,7 ...)
- string hello() must return a string ("one","two","three","four")
- double hello() must return a double (1.232255 etc ...)
- bool hello() must return a boolean (true/false)
- void hello() returns nothing - your case, since you're asking only for an alert()
So you should use :
The third question is about event handler, you'll need : OnStart() (when it starts) ; OnTick() (when a new tick arrive) - for now I suppose it'll be enough.
It's newbie programming but I respect people who wants to learn.
The documentation answers your first two questions:
https://www.mql5.com/en/docs/basis/function
You should maybe get a handle on language basics before attempting your third question.
A general programming book or tutorial may be of use to you.
Your function is correct, but you have to tell it when will be called this function, that's the "event handler".
Then about the return :
- int hello() must return an integer (0,1,2,3,4,5,6,7 ...)
- string hello() must return a string ("one","two","three","four")
- double hello() must return a double (1.232255 etc ...)
- bool hello() must return a boolean (true/false)
- void hello() returns nothing - your case, since you're asking only for an alert()
So you should use :
The third question is about event handler, you'll need : OnStart() (when it starts) ; OnTick() (when a new tick arrive) - for now I suppose it'll be enough.
It's newbie programming but I respect people who wants to learn.
The documentation answers your first two questions:
https://www.mql5.com/en/docs/basis/function
You should maybe get a handle on language basics before attempting your third question.
A general programming book or tutorial may be of use to you.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I'm new to programming, I have some questions, one is that I can't understand what does different returns mean, for example
return(0) , return(NULL), return(INIT_SUCCEEDED)
my second question is that how can I go from a function to another one, for example
function a ()
{
if (condition = true) go to function b (),
}
function b()
{
}
the third question is that what functions is necessary to be in our expert advisor because when I delete all the default functions and I start to write a function like below, it doesn't work and show error
thanks for your help