Questions from Beginners MQL5 MT5 MetaTrader 5 - page 818

 
Vladimir Karputov:

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.

 
User_mt5:

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.

 
User_mt5:

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.

 
User_mt5:

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.

 
fxsaber:

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...?

 
Vladimir Karputov:

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.

1. Yes. So far I've got a 3-dimensional array of only handles. But now, apparently, I'll rearrange it all.

2. Yes, there are almost all codes of technical indicators. And you can write your own.

Thank you.

 
User_mt5:

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?

 
Alexey Viktorov:

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.

 
fxsaber:

MetaQuotes can create such a Standard Library if desired. The big question is, is it needed?

This is for future generations. I've looked at some examples from the library. Thousands of lines of uncommented code. I don't know about anyone, but I can't do that. So thanks for the idea, but it's just not acceptable in my case.
 
User_mt5:
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 MQL5

Perhaps someone will find the MQL4 approach useful in working with tick history as well

if (Tick[0].bid > Tick[100].bid) // сравниваем текущий и исторический тики
  Print("Hello World!");

if (High[0] > Close[100]) // https://www.mql5.com/ru/forum/42122/page24#comment_2904023
  Print("Hello World!");

Technically, nothing prevents you from doing the same thing ONE time with indicators (with no loss of efficiency) and putting the solution in SB.

Reason: