Features of the mql5 language, subtleties and tricks - page 225
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
Another sudden MQL nuance - virtual methods are not called from constructors.
in code
you can't do it like this :-)) OnAttach of the parent class will be called from the constructor ; And during normal access - of the child class.
youcan't understand it, you have to memorise it:-)
Another sudden nuance of MQL - virtual methods are not called from constructors.
in the code
you can't do it like this :-)) OnAttach of the parent class will be called from the constructor ; And during normal access - of the child class.
youcan't understand it, you have to memorise it:-)
Why is it impossible to understand? Initialisation of a pointer to a method in the table of virtual methods takes place in the constructor. The constructor of the parent class is called first, then the constructor of the successor. Accordingly, when the body of the parent class constructor is executed, in the virtual methods table the pointer points to the address of the base class method.
PS. This is for the eternal cholivar about whether you should learn C++. If you study it, digging to the essence of things and not cramming, such things become self-evident).
Why is it impossible to understand? Initialisation of a pointer to a method in the table of virtual methods takes place in the constructor. The constructor of the parent class is called first, then the constructor of the successor. Accordingly, when the body of the parent class constructor is executed, the pointer points to the address of the base class method in the virtual methods table.
PS. This is for the eternal cholivar about whether you should learn C++. If you study it, digging to the essence of things and not cramming, such things become self-evident).
After scripts, where everything is possible, it is a bit surprising that "a constructor cannot be virtual" :-))
after scripts, where everything is possible, it is a bit surprising that "a constructor cannot be virtual" :-)
For your "trouble", there is such a solution: https: //habr.com/ru/post/64369/.
PS. Not exactly the same, of course, but as a general direction of thought
after scripts, where everything is possible, it is a bit surprising that "a constructor cannot be virtual" :-)
unexpected?
Imagine if HiLow::OnAttach was called. If there were new fields in HiLow and OnAttach would read them, there would be "use of uninitialised variables" (because HiLow constructor has not started executing yet).
POSITION_TIME_UPDATE is relevant only in changing the lot of a position. For example, partial closing of a position on any type of account or a refill on netting.
Changes in SL/TP levels do not affect POSITION_TIME_UPDATE.
To paraphrase, POSITION_TIME_UPDATE is affected only by modifications reflected in the Trading History - trades. SL/TP-levels do not belong to such modifications, so they do not affect them.
Yes, indeed, it is so on a real account.
But after building the Expert Advisor, I try it in the tester, and it turns out that in the tester, modifications of SL/TP-levels affect POSITION_TIME_UPDATE.
Here is an excerpt from the logs.
Here I have highlighted the time of position opening in yellow, and then (on the next tick) in red the time of modifying (placing) SL and TP to it. Then I check the POSITION_TIME and POSITION_TIME_UPDATE times using the print -they are different.
Where modification of SL and TP is within the same second, POSITION_TIME and POSITION_TIME_UPDATE times are of course the same.
Thanks for the information!
The ORDER_TIME_SETUP_MSC field changes when orders are partially executed.
As a consequence, DEAL_TIME_MSC can be less than ORDER_TIME_SETUP_MSC of its order.
Example.
Could you please tell me how to compile all files in a directory?