![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
It is better not to start there. This is what scares you away. Even I, a supporter of OOP who knows it very poorly, stumbled because of this text... ...did not understand anything. That's why I'm trying to explain the difference at the lowest level.
It can also be simpler.
OOP - allows you to define a single interface. After that, all platform-specific things "hide" and do not interfere with the work.
Of course, you can do it in a purely procedural approach. But, supporting procedural variant will be more complicated, due to the fact that in each function we will have to deal with all platforms at once.
I apologise for the slight delay.
Here is the first version of the function. You can refine and develop it further. If anyone notices a mistake, please comment.
Respectfully.
Here is the first version of the function. You can refine and develop it further. If anyone notices a mistake, please comment.
At first glance, everything seems to be OK. I haven't dug very deeply.
I personally would probably just divide the previous and current time by the bar duration, and if the value has changed, a new bar would appear. But, it's also possible to do it this way.
As for the style - personally I'm a bit bothered by the fact that you can't tell what type of variable it is (I'm used to "Hungarian notation, when the prefix of any variable is an abbreviation of its type), but maybe that's unnecessary.
@Peter Konow even without OOP you can make it easier, think about it and try it.
Respectfully.
@Peter Konow even without OOP you may make it simpler, think it over and try.
Sincerely.
As far as I understand it correctly. The aim is to make it work. If he had posted a protected file with this function, you would never have guessed that it was written this way.
At first glance, everything seems fine. I haven't dug deep enough.
Personally, I'd probably just divide the previous and current time by the duration of the bar, and if the value has changed, a new bar has arrived. But, it's also possible to do it this way.
As for the style - personally I'm a bit bothered by the fact that you can't tell what type of variable it is (I'm used to "Hungarian notation, when the prefix of any variable is an abbreviation of its type), but maybe that's unnecessary.
Well, perception of style is a matter of habit. I, too, find it hard to read codes given in branches. It just pisses me off sometimes.))
It can also be simpler.
OOP - allows you to define a single interface. After that, all platform-specific things "hide" and do not interfere with the work.
It can, of course, be done in purely procedural approach. But, supporting the procedural variant would be more difficult, due to the fact that in each function you would have to deal with all platforms at once.
It has already been discussed that a single interface is not applicable to programming any computational tasks... Putting nice things in the form of interfaces is purely a cosmetic procedure that is applicable only to the already completed code and which further hinders the support and refinement of the code...
As far as I understand it correctly. The aim is to make it work. If he had posted a protected file with this function, we would never have guessed that it was written this way.
best regards.