Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 166
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can you show me on my function how to do this? I'm really struggling to understand it.
You have to decide which variables from the function you need (for the main program) and pass/retrieve them. If you need All, then declare these variables at the beginning of the program and they will be visible to all functions at once.
Don't think 'why', better to think 'how'.
I told you, it doesn't apply to this function...
Such functions are big, as a rule, that's why it's a pity to call them for execution several times in order to get different values, but I want to get all 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.
the same types can be combined into a structure and declared as an array, as suggested above)
The same types can be combined into a structure and declared as an array, as suggested above)
This is already difficult to understand... for example, I can't understand i - to what it's equal and, shouldn't the ORDERS[i]= array be given a size?
This is already difficult to understand... for example, I can't understand i - what is equal and, shouldn't the ORDERS[i]= array be sized?
This is just an example, of course i needs to be specified and the size of the array needs to be adjusted according to the number of orders...
i.e. the variables are sort of the same tp / sl / lot ... but the index of array i changes
It pains me to see your anguish... You are on a technical forum, use logic, please.
1 Describe the problem;
Describe the variables you are using;
Describe what you want to get as an output;
Learn to express your ideas in a technical language on a technical forum. Otherwise, it will take a long time to guess here.
This is for example, of course i need to specify and set the size of the array depending on the number of orders...
i.e. the variables are sort of the same tp / sl / lot ... but the index of the array i changes
Yes, I got it, thanks, I should try to use it in the future, somewhere.... I just do not understand, and work with this structure as an array? Sort and perform other standard operations?
It pains me to see your anguish... You are on a technical forum, use logic, please.
1. describe the problem;
Describe the variables you are using;
Describe what you want to get as an output;
Learn to express your ideas in a technical language on a technical forum. Otherwise, it will take a long time to guess here.
Please write where there is no logic in my words?
Torment in knowing is pleasure in solving.
I didn't want to spill my problem, so I kept it simple - I find it difficult to guess what caused the difficulty in perceiving... Sorry if I made you feel uncomfortable with my "anguish".
I.e. the idea is to declare all variables in advance, and then change them through a function - got it, thanks for the variant. But, it's not always convenient if one and the same variable name is used for the same kind of variables... no other options?
Read carefully here and you'll see what's going on. This describes the first option, which was proposed, parameter passing by reference.
Simply put, when a function is called, the variable can be passed by parameter
or by reference if the variable name is preceded by an & sign.
In the second variant, the variables passed to the function by reference will be changed along with the variables that have even different names. In the special case these are variables i and j
Everything else is clear enough from the help text.