For example :
ExampledFunction(string Txt, double ProfitFromOrder)
{
... expression... ;
... conditions... ;
return (Txt, ProfitFromOrder);
}
If YES, then what the type should I declare for the FUNCTION as above example: double, string or the other ONE?
Then I would like call this function in start(){...} part of program.
The ExampledFunction() should return two parameters. Is it possible ?
Yes, it is possible.You can declare the function type void and assign the two different type results to two global variables.
Yes, it is possible.You can declare the function type void and assign the two different type results to two global variables.
The ExampledFunction() should return two parameters:
1/. Txt as string type
2/. ProfitFromOrder as double type
How to call this function in start() {...} part of program and compare the two data types with the other variables ?
The ExampledFunction() should return two parameters:
1/. Txt as string type
2/. ProfitFromOrder as double type
How to call this function in start() {...} part of program and compare the two data types with the other variables ?
here is an example:
double A;
string B;
int start()
{
ExampledFunction();
// here check what A & B contain
return(0);
}
void ExampledFunction()
{
// some code
A = your double value;
B = your string value;
}
How to check what A & B contain ? Can you please any MQL4 example ?
it depends what info A and B contain.
for example if A contains order profit:
if(A>0) Print("Profitable trade");
else Print("Losing trade");
it depends what info A and B contain.
for example if A contains order profit:
if(A>0) Print("Profitable trade");
else Print("Losing trade");
you wrote:
void ExampledFunction()
{
// some code
A = your double value;
B = your string value;
}
Should not be there the return (B,A) at the end of declared function ?
you wrote:
void ExampledFunction()
{
// some code
A = your double value;
B = your string value;
}
Should not be there the return (B,A) at the end of declared function ?
I'm sure. In ExampledFunction you change the values of A and B and store there what you want without using return. You first call the function then check the values.
Yes, it is possible.You can declare the function type void and assign the two different type results to two global variables.
No!
Don't use global variables!
The only correct way is the following: (the & before the variable name in the declaration means: by reference, this is effectively a function argument through which you can pass data both ways, you are creating a wormhole through which the function can manipulate something outside but without being restricted to always the same hardcoded global variables only, you can instead call it with any variables you want.)
void ExampleFunction(string &Text, double &Profit){ // ... // do some stuff // ... Text = something; Profit = somethingelse; } int start(){ string SomeText; double SomeProfit; string SomeOtherText; double SomeOtherProfit; // ... // some other stuff maybe // ... // now call the function with the uninitialized variables ExampleFunction(SomeText, SomeProfit); // now the two variables contain the "return" values // now call it again with some other variables ExampleFunction(SomeOtherText, SomeOtherProfit); // this time it will have manipulated the other two variables }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
ExampledFunction(string Txt, double ProfitFromOrder)
{
... expression... ;
... conditions... ;
return (Txt, ProfitFromOrder);
}
If YES, then what the TYPE should I use in order to properly DECLARE the FUNCTION as above example: double, string or the other ONE?
Then I would like call this function in start(){...} part of program.
The ExampledFunction() should return two parameters:
1/. Txt as string type
2/. ProfitFromOrder as double type
Is it possible ?