Features of the mql5 language, subtleties and tricks - page 167
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
didn't think you would have any trouble reading the short code, then read the helphttps://www.mql5.com/ru/docs/trading/ordercalcmargin
Thanks, already figured it out )
I just started to learn MQL5. I must have put my question in a wrong place
Cross-platform difference ArrayCopy.
Obviously, in order to make no difference, you have to write
either
or all default in this context
Obviously, in order to make no difference, you have to write
either
or all default in this context
Here's the problem.
If the function returns zero, then MQL4 and MQL5 will have different results.
Here is the problem.
If the function returns zero, MQL4 and MQL5 will have different results.
So, GetAmountToCopy() solves this problem in case the function should return zero.
For example:
Here is the problem.
If the function returns zero, MQL4 and MQL5 will have different results.
It is not quite clear what you are calculating there. There can be several variants of return from GetAmountToCopy().
If 0 is to copy nothing (this is the condition which causes the problem, as I understand it) and -1 is to copy the entire array, you should obviously specify return values other than 0 and -1 in case you want to copy nothing. For example, return EMPTY_VALUE. In this case we should probably overload the ArrayCopy() function which will first check what is passed to it from GetAmountToCopy(). If it is EMPTY_VALUE, then exit the function. For the rest, if the WHOLE_ARRAY constant is used, the size of data to be copied in both MQL5 and MQL4 will be selected correctly.
It's not very clear what you're calculating there.
It's not quite clear to me why you're writing about possible implementations of MQL4/5 differences. I just noted these differences for those who write cross-platform code.
The differences have already accumulated for an article. Someone should write it.
I'm not quite sure why you're writing about possible workarounds to the MQL4/5 differences. I just noted these differences for those who write cross-platform code.
The differences have already accumulated for an article. Someone should write it.
I thought it was a question. Good. I can delete my messages.
Only suspected before, now confirmed. It's easy to get memory leaks when working with resources.
Example.
A script via SB prints a graph of a numeric array to a chart. You can then manually delete this chart (object), but the resource assigned to this chart will remain forever hanging in memory in read-only mode. It cannot be deleted, because only the owner script can delete it (see the highlighted line).
There is no functionality in MQL to free up so occupied memory. Be especially careful with this on VPS.
Only suspected before, now confirmed. It's easy to get memory leaks when working with resources.
Example.
A script via SB prints a graph of a numeric array to a chart. You can then manually delete this chart (object), but the resource assigned to this chart will remain forever hanging in memory in read-only mode. It cannot be deleted, because only the owner script can delete it (see the highlighted line).
There is no functionality in MQL to free up so occupied memory. Be especially careful on VPS.
When you get a message about a memory leak, it means that there was no explicit command to free that memory.
When a program terminates (which is when you get these messages), it frees up all memory, including the leaked memory, in any case.