Features of the mql5 language, subtleties and tricks - page 320
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
Try this:
Result:It does, indeed, make a difference! Thanks.
Forum on trading, automated trading systems and testing trading strategies
Libraries: TicksShort
fxsaber, 2025.11.18 12:57 pm.
Absolutely free compression performance has been raised by almost 40%!
If real division is executed millions of times, it is reasonable to replace it with multiplication.
Where similar code can be executed millions of times.
Who knows JSON, please share a ready solution with the functionality of these two buttons.
Should create and read exactly the same json as MT5 does through the labelled buttons on the screenshot.
Need for a public torrent with backtest data. Thanks.
Question about macros. I want to set a variable x5 to the value 5 through a macro, compiling the name of this variable.
This code does not compile:
char x3 = 0, x4 = 0, x5 = 0, o = 0; #define num o #define mcr(z) x##z = 5; #define macro(z) o = z == 3 ? 5 : 3; mcr(num) macro(3) Print("x3 = ",x3,", x4 = ",x4,", x5 = ",x5);As I think the problem is that the value of variable o is not passed to mcr. Is there any way to solve this problem?
Question about macros. I want to set a variable x5 to the value 5 through a macro, compiling the name of this variable.
This code does not compile:
As I think the problem is that the value of variable o is not passed to mcr. Is there any way to solve this problem?
The compiler cannot resolve a (future) runtime value to expand the macro mcr(num) at compile-time.
The mcr(z) is using the concat operator (##), thus it must be resolved (expanded) at compile-time only.
The compiler cannot determine the (future) runtime value for the mcr(num) macro extension at compile time.
The mcr(z) macro uses the concat operator (##), so it should only be allowed (expanded) at compile time.
Understood.
Is there any other way to solve this task? Is it possible to set variable names through conditions?
The condition must be resolved at compile time. This can be done using #ifdef and #ifndef.
Such code will not compile either.
o is already equal to 5 and the x5 variable is defined. Where is the error?
Such code will not compile either.
o is already equal to 5 and the x5 variable is defined. Where is the error?
The preprocessor knows nothing about the value of 'o' or any variable.
What are you REALLY trying to achieve ?
Such code will not compile either.
o is already equal to 5 and the variable x5 is defined. Where is the error?