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
And then you have to look up what those four brackets at the bottom refer to.
By the way, it makes me very nervous when nesting is more than two levels. I try never to write it that way, spreading code over functions.
And even when there are two levels of nesting - be sure to write comments after each closing bracket - which block it buries (say, duplicate loop header).
As for style, here's my code for selectinga history position for MT5 (by a specified magician, symbol, with a specified date range):
The history class itself is a descendant of the CTradeHistoryI abstract interface:
By selecting the required history - you can recalculate its components (positions for MT5 or orders for MT4), and get an interface to any component as an abstract interface:
For MT4 - there are corresponding history classes also inherited from these interfaces - thus, at the same time, the cross-platformity is provided - an EA does not need to find out where it works, all work with the history is done through the abstract interfaces.
Don't write functions that are always constant and never change in this style
Write them concisely, no one ever looks at them anyway, and they take half as many lines
Since these functions don't change, why did you put a bunch of unnecessary curly brackets there? Remove them, and everything will be compressed. Because your example looks absurd: you yourself have blurred the code and then invent crutches to reduce it.
I agree, you can cut out 3 more lines, and shorten the code, but the purpose was not to put the code to use, it is in fact not even mine, but to shorten, and such functions can be put five in one screen, not one. After that the programs are easier to read and you don't have to scroll 150 times. And the weight of the file decreases.
Nice work, I like it, but I don't like OOP and try to do without it. I don't like processors with thread division (for example, 4 cores and 8 threads). It must be clear that division and any virtualization is a loss of performance and loss of machine time for its implementation, be it thread division in the kernel or virtualization of functions in the code.
I agree, you can cut out 3 more lines, and shorten the code, but the purpose was not to put the code to use, it's not even mine in fact, but to shorten it, and you can put five such functions in one screen, not one. After that the programs are easier to read and you don't have to scroll 150 times. And the weight of the file is reduced.
Sincerely.
27" working screen
I'm not going to reread it, I'll just quote:"Don't write functions that are always constant and never change in that style"
Why pick your eyes over a function that is written once when the platform is released and will never change in the future? Do you often change/edit the code in the functions to get lot size, number of orders and typical? Then why stretch it across 3 screens of a 32" monitor?
P.S. The code attached is forged from kodobase.
Counter question ))) I have such functions are in MyFunc.mqh file, I do not see the slightest sense in compressing it. Why, to save 10-20 KB on disk? And frankly speaking, such codestream makes me sick ))
Counter question ))) I have such functions in file MyFunc.mqh, I don't see the slightest sense in compressing it. Why, to save 10-20 KB on disk? To be honest, this codestream makes me sick )).
As for me, the code should be clear, short, fast to work and should work in all conditions without errors.
Sincerely.
Counter question ))) I have such functions in file MyFunc.mqh, I don't see the slightest sense in compressing it. Why, to save 10-20 KB on disk? And frankly speaking, such a codestream makes me sick ))
So, count: 1000 EAs x 10 Kb = 10 Mb - you already have to think about economizing ))
Counter question ))) I have such functions in file MyFunc.mqh, I don't see the slightest sense in compressing it. Why, to save 10-20 KB on disk? And frankly speaking, such codestream makes me sick ))
Me too, but long ago I came to the conclusion that the code must be compact in places where one never looks at it, where it is never corrected and never will be corrected.
Scattering user code with all over the inludes is an additional headache, when you need to drag and drop a file into another terminal, or share it, you will need to drag and drop several files. Of course, you can transfer the includniks to all terminals, but if you change or add something in one terminal, then all of them must be replaced with a new one.
The Expert Advisors and indicators are so small that there is no point in distancing them from the body of the program. To be more correct, they are not small, they are single file, it's not like a site with 10 000 pages where you cannot do without classes and inludes. Moreover, there are structures now, and they are enough to write compact, 100% workable code.
By the way, it makes me very nervous when nesting is more than two levels. I try never to write it that way, spreading code over functions.
And even when there are two nesting levels - be sure to write comments after each closing parenthesis, which block it buries (say, duplicate loop header).
As for style, here's my code for selectinga history position for MT5 (by specified magician, symbol, with specified date range):
The history class itself is a descendant of the abstract CTradeHistoryI interface:
By selecting the required history - you can recalculate its components (positions for MT5 or orders for MT4), and get an interface to any component as an abstract interface:
For MT4 there are corresponding history classes which also inherit from these interfaces - thus at the same time the cross-platformity is provided - the Expert Advisor doesn't need to find out where it works, all work with the history is done through abstract interfaces.
Looks nice, can we also look at TRACE_*** and ASSERT?
To drag and drop a file to another terminal, or to share it, you need to drag not just one file, but several. You can, of course, transfer the inludes to all terminals, but if you change or add something in one terminal, then you need to replace it with a new one in all terminals.