Questions from Beginners MQL5 MT5 MetaTrader 5 - page 818
![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
I hope you create indicator handles ONE time in OnInit()?
Calculation depth depends on the indicator. Rare indicators limit the depth forcibly - as a rule, all of them calculate the entire history. Therefore, the following variant may be useful: to introduce the variable responsible for the depth in the indicator and then to pass this parameter through iCustom in the Expert Advisor.
1. Yes, I understand that in a good way it should be done once in the init. But the issue is that indicator input parameters may vary. For example, in spectrum analysis the resonant frequencies are calculated and the result of the calculation is the period of the MA used. And if you request MA data for a new dimension, it's a new handle. Practically frequencies do not change on every bar, so the same MA handle is used long enough (~ minutes). But still, there comes a time when the handle changes. And then I either need to use a bunch of handles, or use a single handle, but recalculate it periodically. That's where the economy comes in.
2. iCustom I have mastered. But how to limit the calculation depth in the indicator? I cannot do it in technical one. Apparently, I will have to create a lot of custom clones of technical indicators. Of course, it is annoying but it should be effective. Thanks for the tip. It's a good idea. Thank you.
1. Yes, I understand that this is normally done once in the inite. But the question is that input parameters of indicators can change.
The developers can write SB where indicators can be handled in MQL4-style without losing their efficiency. I.e. all caches and handles are hidden in SB.
1. Yes, I understand that this is normally done once in the inite. But the issue is that the input parameters of the indicators can vary. For example, in spectral analysis the resonant frequencies are calculated and the result of the calculation is the period of the MA used. And if you request MA data for a new dimension, it's a new handle. Practically frequencies do not change on every bar, so the same MA handle is used long enough (~ minutes). But still, there comes a time when the handle changes. And then I either need to use a bunch of handles, or use a single handle, but recalculate it periodically. That's where the economy comes in.
2. iCustom I have mastered. But how to limit the calculation depth in the indicator? I cannot do it in technical one. Apparently, I will have to create a lot of custom clones of technical indicators. Of course, it is annoying but it should be effective. Thanks for the tip. It's a good idea. Thank you.
1. In that case it's probably better to kill an unused handle and create a new one (the main thing is to control, so as not to slap a million handles into OnTick() :) ).
2. Create a copy of the built-in indicator, but with a different name (for example, add "depth of history" to its name) and introduce a new parameter: InpDepthHistory. That is, you need to write new custom indicators.
1. Yes, I understand that this is normally done once in the inite. But the issue is that the input parameters of the indicators can vary. For example, in spectral analysis the resonant frequencies are calculated and the result of the calculation is the period of the MA used. And if you request MA data for a new dimension, it's a new handle. Practically frequencies do not change on every bar, so the same MA handle is used long enough (~ minutes). But still, there comes a time when the handle changes. And then I either need to use a bunch of handles, or use a single handle, but recalculate it periodically. That's where the economy comes in.
2. iCustom I have mastered. But how to limit the calculation depth in the indicator? I cannot do it in technical one. Apparently, I will have to create a lot of custom clones of technical indicators. Of course, it is annoying but it should be effective. Thanks for the tip. It's a good idea. Thank you.
As far as I understand you want to get only 1 value using iCustom() as in mql4, but you don't consider that mql4 also recalculates the indicator for the entire history depth at the first use. The same way it is recalculated at a change of at least one parameter.
Therefore, we conclude: You should not bother. If the "old" indicator is not needed, you can simply delete it and get a handle of the indicator with other parameters.
Developers can write a SB where indicators can be handled in MQL4-style without losing efficiency. I.e. all caches and handles are hidden in the SB.
Sorry, I don't understand. Is the word Developers here the ones who created MT or am I a sinful application? And SB is...?
1. In that case, it's probably better to kill an unused handle and create a new one (the main thing is to make sure you don't slap a million handles into OnTick() :)) ).
2. Create a copy of the built-in indicator, but with a different name (for example, add "depth of history" to its name) and introduce a new parameter: InpDepthHistory. That is, you should write new custom indicators.
2. Yes, there are almost all codes of technical indicators. And you can write your own.
Thank you.
Sorry, I don't get it. Is the word Developers here the ones who created MT or am I a sinful applicationist? And SB is...?
MetaQuotes can create such a Standard Library if desired. The big question is, is it needed?
As I see it, you want to get only 1 value using iCustom() like in mql4, but you don't consider that mql4 also recalculates the indicator for the entire history depth at the first use. In the same way, it is recalculated when at least one parameter is changed.
Hence the conclusion: No need to bother. If an "obsolete" indicator is no longer needed, you can simply delete it and get a handled indicator with different parameters.
Maybe, I do want to. But now I don't want to. You are right. If you don't need an obsolete indicator, you should crush them like cockroaches :)
A good solution is to limit the depth of technical clones. It will save resources and time. So, that's what I'm going to do now.
Thank you.
MetaQuotes can create such a Standard Library if desired. The big question is, is it needed?
This is for future generations. I looked at some examples from the library. Thousands of lines of uncommented code. I don't know about anyone, but I don't know how to do that. So thanks for the idea, but it's just not acceptable in my case.
This already works in MT5
Forum on trading, automated trading systems and trading strategies testing
Features of mql5 language, subtleties and tricks
fxsaber, 2018.01.09 10:20
For MQL4 adepts there is an ancient way to handle TFs in MQL5Perhaps someone will find the MQL4 approach useful in working with tick history as well
Technically, nothing prevents you from doing the same thing ONE time with indicators (with no loss of efficiency) and putting the solution in SB.