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
Yes? Doesn't it create a new, independent object?
Let's check now - I'll insert lines like this:
as well as
and a test script:
Result:
One object is created, then a SECOND one (it turns out there is no recreation - a new one is created), BUY position is opened with magic "0" - i.e. the second object "trade" opened it.
Then we see that the two objects are destroyed in reverse order: first the second one (with magic "0") and then the first one (with magic "123").
Yes? Doesn't it create a new, independent object?
Yes, it will create a new instance of theCTrade class
andeven more, CTrade destructor will be calledat exit from void OnTick() and at the next OnTick() CTrade constructor will be called again
yes, there will be a new instance of theCTrade class
If the void OnTick() is exited, the CTrade destructor will be called, and the next OnTick() will call the CTrade constructor again.
Yes I realised that immediately after Artem's answer.
Forum on trading, automated trading systems and strategy testing
OOP for Schoolchildren.
Artyom Trishkin, 2019.10.08 20:23
It's exactly the same as with variables.
And the focus:
In my opinion, mql has a very narrow set of tasks that need to be solved through OOP. The language itself seems to me to be nothing more than an OOP in C++ or something. And this OOP is offered in the form of a standard library. And to this OOP it is suggested to add, otherwise I wouldn't say, another OOP. And then another step... Rightly said Warlock, though angry, but benevolent, for my tasks OOP is like a dog turntable. And what good is setting a problem and its subsequent realization by means of OOP if this problem without problems can be solved in procedural style.
Here for example to take .mqh from fxsaber`a to write codes for MT5 as well as for MT4. Maybe someone needs it, but look who. Those who do not want or absolutely cannot master mql5. Or take iCanvas from Nikolay ... I forget his last name. It seems to be a useful library, but it is not easy to understand it, and there is no documentation, even a smallest description. It's not a complaint, sorry Nikolay, it's a fact. So, when I decided to try writing a graphical label, it was easier to write it without reference to either standard library or Nikolai's library.
Actually, Alexey, you can get enough information about iCanvas from the description page in KB.https://www.mql5.com/ru/code/22164. You need to study the comments in the code carefully. The meaning of all the functions is intuitive from their names.
But you might be right. I should record a video of writing some simple but useful indicator using iCanvas and explain visually some features of this class. There are still some subtleties.
Frankly speaking, I do not like how iCanvas is written right now. I want to crumple it up, throw it in the trash and rewrite it in a more correct style.
70% of the code in this library is about speeding up some of the regular functions that are needed to handle coordinates and data access.
So, if you apply this class, the graphics will be faster than if you do it "head-on" with CCanvas. That's its main feature and advantage. And, of course, it is really easier to form graphs, figures, comments.
I would also like to add, Alexey, that the purpose of many publications in CodeBase, including fxsaber and my publications is an unselfish "just to share - who needs it, will understand it". So often spending time on detailed instructions is simply a bummer.
Especially in the forum, I have posted many short and illustrative examples using iCanvas.
Here, for example:
https://www.mql5.com/ru/code/25929
https://www.mql5.com/ru/code/25113
https://www.mql5.com/ru/code/25414
https://www.mql5.com/en/code/24798
https://www.mql5.com/ru/forum/227736/page41#comment_13259627
https://www.mql5.com/ru/forum/227736/page24#comment_12836622
https://www.mql5.com/en/forum/323629#comment_13442470
https://www.mql5.com/ru/forum/321704#comment_13131995
https://www.mql5.com/ru/forum/317257/page3#comment_12341593
https://www.mql5.com/en/forum/229521/page2#comment_10258148
Actually, Alexey, you can get enough information about iCanvas from the KB description page. https://www.mql5.com/ru/code/22164 You have to study the comments in the code carefully. The meaning of all functions is intuitively clear from their names.
Nikolai, don't pay any attention to my words. There are so few people like me among those who study programming, if I'm not the only one, that it's not worth paying attention to them at all.
For me to learn comments in code, you first have to learn Aglitsky)).
If I had an urgent need I could spend time and translate all comments, try to understand machine translation and make corrections. But there is no such need.
For example, take .mqh from fxsaber`a to write codes for MT5 as well as for MT4. Maybe someone needs it, but look who... Those who do not want to or absolutely cannot master mql5.
I think I know MQL5 pretty well, but I have a need for a trading library. I am not talking about MT4-style, but about a trading library for MT5, which would be comfortable and fast to work with. And this library has no bugs during real trading.
Since such a library wasn't available (and I don't know if it exists) in the public domain, I had to develop my own one. For this purpose I had to decide, what kind of a tool in the form of a setof trading functions I was going to invent. Borrowed the MT4-set, as a pretty good one. Which, as a bonus, made it possible not to write the documentation to the library and to study it. And other goodies.
So knowledge of MQL5 is sometimes at a high level among users.