Questions from a "dummy" - page 52

 

Does it have to go somewhere? ... I don't know...

I mean, it flies on the EMA, but it takes 10 times longer on the iCustom...

 

You should never do this:

void OnTick()
  {
   //--- безусловно создаем индикатор
   ma_handle = iMA(_Symbol,0, MA,0, MODE_EMA, PRICE_CLOSE);
  }

Don't be fooled into saying"get the indicator handle" when in realityyou are "creating a new indicator".

Besides, there is a leakage of handles.

 
Karlson:

Does it have to go somewhere? ... I don't know...

I mean, it flies on the EMA, but it takes 10 times longer to run the iCustom...

Where should we put a bunch of obsolete Handles-Indicators? I don't know. I haven't worked that way. There are more and more of them with every tick.

If I had to implement such a strategy, I would refuse from calling a ready custom indicator through iCustom() and place the indicator body in OnTick() of the Expert Advisor instead. And the calculations of the data would be performed by the Expert Advisor itself.

..The problem will arise if the indicator is in .ex5 format and there is no code.

 

I remembered: " IndicatorRelease() function is used to release an unused indicator from the computer memory and the handle of this indicator is passed to it" (I use it during Expert Advisor deinitialization).

But all the same: a new handle at every tick is troublesome.

 

About the accumulation of handles, I'll look into it.

That's what I plan to do, put the turkey in the EA.

 
Karlson:

About the accumulation of handles, I'll look into it.

That's what I plan to do, put the turkey in the Expert Advisor.

You can leave the indicator as it is and create a copy of it in the timer or by event.
 
Interesting:
You could leave the indicator as is and create a copy of it in a timer or by event.

What is the difference where to create a copy of the indicator: in OnTick(), OnTimer() or in OnChartEvent()? In any case, every special activation will create a "copy of the indicator", aggravating the already huge pile.

Or maybe I don't understand your logic.

 
Yedelkin:

What is the difference where to create a copy of the indicator: in OnTick(), OnTimer() or in OnChartEvent()? In any case, every special activation will create a "copy of the indicator", aggravating the already huge pile.

Or maybe I don't understand your logic.

Here's the trick - If you don't need to change the indicator parameters (no need to create a new copy of the indicator), then it's more logical to create the indicator once in the initialization block.

But if in the course of working the indicator parameters should be automatically changed, we should do it as effectively as possible.

The most efficient way is to create a new copy of the indicator in the timer (not necessarily at every tick).

The most effective way would be to create a new copy of the indication when some event (a few events) occurs.

PS

It is necessary to take into account the time spent on calculating the indicator and make sure to get rid of "unnecessary" copies.

 

Such an idea for consideration...Recalculating a new bag can be done once a day or a week for me...Setting a timer:

bool  EventSetTimer(
   int  seconds      // количество секунд
   );

Really confused by the number of seconds in a day or week...))) You can also do it on a new daily bar...

In the OnTimer() function, I first remove the previous indicator withIndicatorRelease(), then create a new one with a new period.

void OnTimer() 
{

IndicatorRelease( ma_handle );

ma_handle=iMA(Symbol(),0,newMA,0,MA_EMA,PRICE_CLOSE);

}

That's a general idea...

 
Renat:

You should never do this:

Don't be fooled into saying"get the indicator handle" when in realityyou are "creating a new indicator".

In addition, there is the leakage of handles.

In the early days of MQL5, a lot of questions were discussed, you have cut an important part of developments for auto-trading, and as a result, people choke your super-optimized OnCalculate() with empty space and put calculations in events. It's a bit slow, but still faster than creating your own handle for each dynamic parameter.

Reason: