Features of the mql5 language, subtleties and tricks - page 201
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
For such cases, here are some auxiliary macros.
1. sometimes you want to determine inside your macro whether a parameter has been set or not. IS_PARAMETER_SET(p) defines an expression, which returns true if p is set (even if string variable ==NULL).
Attention: the expression is evaluated after preprocessing at compile time!!!, i.e. it cannot be used to implement something like #ifdef IS_PARAMETER_SET(p) #else (this also applies to other macros below)
2. If you need to explicitly convert a parameter value to a string, to avoid a compile-time error with an unspecified parameter, you can use __EVAL_STR(p). If p is not specified or explicitly defined with NULL literal, it returns "". Not applicable to arrays, structures and classes.
The explicit conversion of a parameter to a number is __EVAL_NON_STR(p). If p is not set, returns 0. Does not work when p is a string!
Code and examples of use:
The following code on theRannForex-Server demo account can immediately reproduce this situation by running this advisor.
Result.
By the way, the script shows (not always the first time) a bug in the synchronous OrderSend execution.
After OrderSend is executed for a few tens/hundreds of milliseconds, the order price is the old one, and not the one that was successfully placed by OrderSend.
Coming back to the topic of identical tickets, we can draw some conclusions.
If someone has managed to reproduce it on another trading server, please share the name.
Search string: Oshibka 010.
Back to the question of partial execution again.
1. Please clarify on point 3: "You may close the position you have formed without removing the Partial Execution. But if after that the order is triggered, a trade will open with a ticket equal to the ticket of the position you closed before. That is, there may be a situation where you close a position with a certain ticket. And then a position appears again with the same ticket."
In this case, was POSITION_IDENTIFIER equal to POSITION_TICKET or not?
2. Earlier in the "POSITION_TICKET != POSITION_IDENTIFIER" thread you demonstrated a different MT5 logic.
https://www.mql5.com/ru/forum/227423/page2#comment_6543129Conclusions
If we assume that this is normal behavior of MT5, and not a peculiarity of the broker's hack, then
In your experience, is there any general pattern in what cases/modes of working which MT5 uses?
3. Ultimately, have there ever been any real situations where "POSITION_TICKET != POSITION_IDENTIFIER" ?
When calling a macro, it is possible to omit a parameter (leave it out), and sometimes you want to specifically allow a macro to work with an unspecified parameter.
So it turns out that an unspecified parameter in any macro is treated by the compiler as an empty string?
In a way, yes, although maybe "like an empty space" is a better word. Difficult to articulate clearly :-(.
But #p definitely turns into string ==""
In a way, yes, although maybe "like an empty space" is a better word. Difficult to articulate clearly :-(.
But #p definitely turns into string ==""
Thanks, interesting nuance.
@fxsaber
Look up this issue, please: https://www.mql5.com/ru/forum/170952/page201#comment_21964923
Back to the question of partial performance again.
1. Please clarify on point 3: "You can close a formed position without removing the Partial Put Option. But if after that the order is triggered, a trade will open with a ticket equal to the ticket of the position you closed before. That is, there may be a situation where you close a position with a certain ticket. And then a position appears again with the same ticket."
In this case, was POSITION_IDENTIFIER equal to POSITION_TICKET or not?
2. Earlier in the "POSITION_TICKET != POSITION_IDENTIFIER" branch you demonstrated a different logic of MT5.
https://www.mql5.com/ru/forum/227423/page2#comment_6543129In your experience, did you show any general pattern in which cases/modes of operation which MT5 scheme applies?
3. Ultimately, have there ever been any real situations where "POSITION_TICKET != POSITION_IDENTIFIER" ?
Both links talk about different implementations of partial execution. This is determined by the broker's software, not MT5.
No mismatch between ticket and ID has ever been encountered.
Forum on trading, automated trading systems and strategy testing
Libraries: Usage
fxsaber, 2021.05.01 14:17
GetMicrosecondCount may output a value less than on the previous call (without ULONG overflow). Examples of such situations.Each line is obtained by different EAs on three MT4 terminals.
And on MT5 this sort of thing happens, but much less frequently on MT4.
Be careful.