Discussion of article "LifeHack for traders: Blending ForEach with defines (#define)" - page 6
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
How do you imagine an article?! I take my source code from KB and start to describe in the article why I decided to apply a macro in this place and why it is exactly like this?
For each work in KB there is a discussion thread. There you can ask questions about the sources.
How do you imagine an article?! I take my source code from KB and start to describe in the article why I decided to apply a macro in this place and why it is exactly like this?
For each work in KB there is a discussion thread. There you can ask questions about sources.
For example, here I do not beat off hollows at all).
It would not be bad to describe these things!
For example, here's where I don't hollow out at all)
It would be nice to describe these things!
This is a multi-line macro with five input parameters. Look at the text, with which parameters it is called.
It creates corresponding methods named MT4OrderTicket, MT4OrderClosePrice, etc. The methods are 95% identical in text and there are many of them. In order not to make a huge copypaste, where an error can easily creep in, a macro is made. Everything is compact and immediately visible.
Moreover, this code emphasises that the functions are 95% the same. That is, when reading it, you realise it at once. But if you were to write classically, you could make such a conclusion only by reading and analysing the code of 20 methods (there are so many of them). And this is a big headache. And so all 20 methods are on one screen and everything is emphasised that the methods almost coincide. And only the input parameters of macros tell about the differences. You pay attention to these differences and not to the tinsel when reading. I.e. the code shows the main thing at once - the core and not a mundane shell.
The things he's doing are out of the box. That's valuable knowledge that should be shared with the public!
Well, he is sharing it. Some of his posts and descriptions of code in KB are more informative than half of the articles here.
I also don't understand why there is an artificial reference book, if there are live answers from him to all the questions asked.
It would be better if Renat would get rid of his habit of banning him for every harsh statement.
Would the developer make an additional command "make a copy of the file, replace macros without compilation and open the file" to the "Compile" button in the editor. Especially for studying macros from fxsaber.
Or you can use the command in the context menu. Put the mouse on the macro call, select the command, the code obtained after macro replacement is copied to the buffer.
In general, macros can be understood like this:
1. It is necessary to separate the macro name from its value. First in the line goes #define, then a space, after it this name (it can be with parameters), then another space or transition to a new line and the value of the macro.
2. We see how the macro is called in the code, what its parameters are. Make a copy of the macro value and replace the parameters with those parameters with which it is called somewhere in the code.
3. Where the macro is called in the code, replace it with what we got in step 2.
Approximately like this.
There are some things you need to know: \ - it means continuation on a new line. ## - it is a connection of lines.Forum on trading, automated trading systems and testing trading strategies
Features of mql5 language, subtleties and techniques of work
fxsaber, 2017.12.05 11:39 pm.
In debug mode, you can't find out the value that a function or expression returns.
For example
For example, what the highlighted functions returned.
I use (not only in debug mode) this way
Result
I have formatted it as mqh.
Cross-platform script as an example
Let's say we wanted to know what OrderClosePrice() returns in this code. Let's do it like this
And here is the code if you want to know almost everything (it happens when you don't understand at all where the problem is in your own or someone else's code).
I.e. any place whose value you want to see, we put it into _P(). The result
Or, for example, there is such an expression
We need to quickly figure out why 19602 is output. We put the pieces we want to quickly find out into our macro
And we can see the result of the calculation step by step
ZY Instead of a piece of article...
There is a bug, first symbol process is with position_index 0, next one is with position_index 2. You are missing position_index 1 and your loop is executed only os_total-1 times.
In this one there is the same bug as previously.
And additionally you are mixing functions to work on open orders and history selection. If your intend was to work with open orders, there is no need to use HistorySelect().
By the way these bugs demonstrate well the problem with without macro. It's hard or impossible to debug.
The most strongest criticism of using #define is the fact that macro substitutions do not allow for code debugging. I agree with this, although, as fxsaber says, "A reliably fixed patient requires no anesthesia debugged macro requires no debugging".
I stopped reading after that, sorry.
New article LifeHack for traders: Blending ForEach with defines (#define) has been published:
Author: Vladimir Karputov
maybe you considered to add 2 more defines for mql4, OrderCalcProfit() and OrderCalcMargin()