Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 165

 
-Aleks-:

Oof, sounds complicated and unclear, but can I have an example based on my function?
I'm on my mobile. It's a simple example, but you can't write it from a mobile.
 
Artyom Trishkin:
I'm on my mobile. It's a simple example, but you can't write from a mobile.

Well, maybe when you get a chance you can write?

 
-Aleks-:

OK, let's say these :

int TFT=0;
int shiftMAT=0;
int typeMAT=0;
int priceMAT=0;


These variables can be sent to a function or assigned values internally (like you) to make it work.
 
Nikolay Gaylis:

These variables need to be sent to a function or assigned internally (like you did) to make it work. You can't get them.

But you have to get it somehow... That's the idea.

I'm getting these variables via string - but I thought there was a simpler method...

 
-Aleks-:

But you have to get it somehow... that's the idea.

I'm now getting such variables via string - but I thought there was a simpler method...


Do you want to change the values of these variables? I don't understand what you're getting if they're always zero?
 
-Aleks-:

But you have to get it somehow... that's the idea.

I'm now getting such variables via string - but I thought there was a simpler method...


You've been told how to pass variables into a function before

//передаем переменные abc
ABC(a, b, c);

//функция получает abc и использует для себя ABC
void ABC(int &A,int &B,int &C)
{
}
 
Nikolay Gaylis:

Do you want to change values of these variables? I just don't understand what to get there, if they always equal zero?

Don't think 'why', better to think 'how'.

I told you that it doesn't apply to this function...

Functions like this are usually big, which is why it's a shame to call them several times to get different values, but you want to get all the results at once.

Well, for example, I want to get at once the number of all lots and the number of all orders broken down by order type.

 
Taras Slobodyanik:


you have already been told how to pass variables into a function

I'm asking you how to get more than one variable from a function as a result of the function...
 
-Aleks-:

I'm asking how to get more than one variable from a function as a result of the function...


after the function works, the variables ABC will be in abc

ps. you can declare all variables as global and all variables will be visible in all functions and there is no need to fetch/send anything

 
Taras Slobodyanik:

after the function works, the variables ABC will be in abc

Can you show me on my function how to do this? I really have a hard time understanding it.

Reason: