Features of the mql5 language, subtleties and tricks - page 234

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
from where, to where, what and under what conditions was measured ?
just OrderSendAsync MODIFY and to the immediate next operation 5 sec ????
very strange, frightening, improbable result - we need to double-check the tests
I measured the time before and after the function, calculated the difference and got 5 seconds. In combat advisors everything is measured, so that there is more information to sort out an abnormal situation. Saw this.
It was necessary to create structures that could be given different rules of actions inside, but manipulated among themselves as identical.
The technique used was formalised on this example.
Unfortunately, I didn't understand why OOP languages don't have interfaces for static methods.
I have to create such a horror.
How do you imagine it?
Any function has its address in the .text segment.
Any member function (method), implicitly accepts this pointer as its first parameter.
Static methods do not accept the this pointer and are essentially syntactic "sugar", being, de facto, ordinary functions.
When a virtual function is called, the address of the executable function is taken from the virtual function table, the pointer to which is implicitly contained in the class in which the virtual function is declared. Initialisation of the pointer to the executable function occurs when creating an instance of the object, the logic is like this (I write it in mql on purpose so that it would be clear to all neophytes:
Naturally, in reality, everything is not like this, but the mechanism of initialisation of the pointer to the function is exactly like this. Accordingly, there is no way, from the word "at all", to do it the way you want in a compiled language.
C++ has such template magic:
Any function has its address in the .text segment.
Any member function (method) implicitly accepts this pointer as its first parameter.
Static methods do not accept this pointer and are essentially syntactic "sugar", being de facto ordinary functions.
When a virtual function is called, the address of the executable function is taken from the virtual function table, the pointer to which is implicitly contained in the class in which the virtual function is declared. Initialisation of the pointer to the executable function occurs when creating an instance of the object, the logic is like this (I write it in mql to make it clear to all neophytes:
Naturally, in reality, it is not like this, but the mechanism of initialisation of the pointer to the function is exactly like this.
Thanks for the detailed explanation with an example!
What's your idea of that?
If you are talking about my regret about the possibilities of interfaces. I want to impose only syntactic restrictions on classes/structures. That is, only at the compilation stage, as it happens with the same const modifier. For self-control, in short.
There is no way, from the word "at all", to do what you want in a compiled language.
I wrote a crutch above. I wanted to get something already built in for such cases.
Forum on trading, automated trading systems and testing trading strategies
New version of MetaTrader 5 build 3950: Withdrawal/Fill in the terminal and updated trading report
fxsaber, 2023.09.19 23:25
How to get rid of errors?The first time __LINE__/__COUNTER__ are passed inside the markos as text, the second time - numbers.
I came up with two solutions to get round this error.
1. Through the base class:
2. Through a nested class:
If it stops working, it would be good to know if it is correct.
If you make pointers instead of objects, the old version will work too.