Discussion of article "LifeHack for traders: Fast food made of indicators" - page 3

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
...starts making calls with different parameters, multiplies indicators, loses all handles, and then wonders about brakes and memory consumption.
To be honest, I haven't understood how one can lose a handle, if it is stored behind the scenes of MetaTrader.
p.s. In general, let the author of the article join the discussion and explain a few points regarding his vision of working with indicator handles in MT5.
To be honest, I never understood how one can lose a handle if it is memorised behind the scenes of MetaTrader.
With this approach to code quality, I have no more questions.
It is not clear what you mean by what you said. As far as I understand, hendles are not closed anywhere( there are nocalls to IndicatorRelease ). There is a constant call to standard functions of hendle creation, such as iMACD:
Obviously, the whole game here is based on the fact that iMACD and similar functions cache inside themselves the previously returned handle, so there should be no recreation of the indicator.
Yes, I had an initial idea to show that in MQL5 you should work with indicators in a fancy way: one handle should be created in OnInit(), and access to indicator data should be obtained through CopyXXXX functions, and if you use the MQL4 style re-creation of handles, it is very wrong and will be a disaster: it will eat up memory. But in the process it turned out that the MQL5 kernel is so clever (obviously there is internal caching of identical handles) that it does not allow recreating handles.
The side effect is that the MQL5 kernel is so well designed that it allows MQL5 to work in a non-fashionable way.
I did not see any similarities.
Both articles offer the same thing - writing the simplest MQL4-style variant in MQL5. Compare this
Forum on Trading, Automated Trading Systems and Testing Trading Strategies
Discussion of the article "LifeHack for trader: cooking fast food from indicators"
Vasiliy Sokolov, 2018.01.25 16:05
and this
In fact, it is the same thing.
Should they be present? I think the title of the article (or rather its description) clearly says only about indicators?
They should not, judging by the title. But the article touches upon MQL4-style work with time series. And without it, we get an incomplete solution. Almost everyone uses "High[i]" in MQL4. Moreover, the implementation of it is easy to find.
Unfortunately, MQL does not support functions with an arbitrary number of parameters, so iCustom is not possible to implement "just like in MT4"
I don't think it is possible to write a whole full-fledged engine fully emulating MT4 style within one article. The topic was clearly stated: working with indicators in MQL4 style (it's a pity the title of the article does not reflect the topic, which is confusing).
MQL4-style is still a concept, but not a clear adherence to the syntax.
If you use MQL4 style re-creation of handles, it is very wrong and will cause trouble: memory will be consumed.
That's why the question arises, why did they implement incorrect work when it could be done correctly and in the style of MQL4?
MQL5 is not smart, it just has foolproof protection. Otherwise, any accidental error would lead to unfortunate consequences. But the foolproof protection, as performance measurements show, is designed in such a way that there is a failure in performance. That's why it is necessary to shift "re-creation of handle" to MQL5 wrapper, hiding it (a small part of OOP capabilities) from the user's eyes.
... But also the foolproofing, as performance measurements show, is done in such a way that there is a dip in performance ...
Yeah, that's interesting. I'll measure the speed and post my findings here.
Measured it on the simplest of blanks.
The overhead is about three times. So, yes, MetaTrader 5 takes a lot of time to find a cached handle.
I had an idea to test this: an EA similar to"MACD MQL4 style EA short", only in it you can address not two, but three, four, five indicators .... In this context, "indicator" means (using MACD as an example) an indicator with different parameters but one symbol each.
I deleted my previous post because I noticed that MACD MQL4 style EA additionally accesses the graphics subsystem:
I.e. the testing done was performed incorrectly. After commenting the Comment function, the performance is almost equal:
Conclusions: MetaTrader 5 still effectively finds the previously created cache and it is possible to use the proposed codestyle.
But the foolproof protection, as performance measurements show, is made in such a way that there is a performance failure. That's why it is necessary to shift "re-creation of the handle" to the MQL5 wrapper, hiding it (a small part of OOP features) from the user's eyes.
MetaTrader 5 requires quite a lot of time to find a cached handle.
There is no certainty that a user can speed up this process in a general way. Obviously, the overhead is spent on calculating the hash function.
One variant of such an indicator hash function in a general form was posted here
I didn't care about performance there, but it was clear that any hash function input must be an array of MqlParam-values. And this can't work fast taking into account the fact that there is a slow string-field.
Therefore, writing a universal indicator fast hash function much faster than what is built into MT5 is an open task. But I am categorically against calling indicators from somewhere. That's why I don't even want to understand the issue.
There is another thought about smart MQL5. There are a lot of Expert Advisors, where the same indicator is called on each bar, but with different input parameters. MQL5 "shoots" unnecessary handles over time. But this is a universal solution. And in an Expert Advisor, the author can take this responsibility on himself, killing handles by himself. It is obvious that it is super-wasteful in terms of computational resources and memory to carry the baggage of a hundred handles through a hundred bars. But I haven't seen EAs in the same kodobase that would nail a handle like this. Everything is given to the "cleverness of MQL5", thus forcing the authors to be not clever at all.
But again, indicators and bars are evil.
There is no certainty that a user can speed up this process in a general way. Obviously, the overhead is spent on calculating the hash function.
One variant of such an indicator hash function in a general form was posted here
Well, you wanted to dump a lot of information on the reader in one article. But regarding your method - it is a head-on solution, have you tried others? And compared the performance?