Download MetaTrader 5

indicator is too slow

To add comments, please log in or register
Use searching on MQL5.community. It is easy!
meir
13
meir 2015.07.22 06:30 

Hi.
I have my iCustom indicator. When I run my Expert include my indicator I got the message : "indicator is too slow, 3323 ms. rewrite the indicator, please"
What should I do to solve this problem

 

Thanks

Meir 

whroeder1
14480
whroeder1 2015.07.22 11:54  
  1. Change it so it only calculates changed bars.
    int counted = IndicatorCounted();
    int lookback = ... // iMA(period) has look back of period.
                       // buffer[i+2] has look back of 2
                       // use maximum of all.
    for(int iBar = Bars - MathMax(lookback, counted); iBar >= 0; --iBar) ...
  2. Reduce max bars on chart
  3. change it do only calculate visible areas
Frika
30
Frika 2017.03.01 13:03  
Hello,

here the same problem. What I not understand is why there is such a message occur.
My indicator is a simple RSI thing which produce one signal. I tried 15 different pairs  to watch simultaneous. And in each chart I put in the indicator twice.
There is no problem, I never saw this message before.

But then, when I try to catch the signal with an EA with iCustom method with the same indicator and check if there is a signal only at the first tick in each bar, there is one hour nothing
and then suddenly each minute comes the message. Then awhile no message and then 10 in one minute.

So, what is going on in this EA with the iCustom. Is this any thread thing which can´t play together, or what is the problem in this thing?

Thank you
whroeder1
14480
whroeder1 2017.03.01 13:43  
Frika: here the same problem. What I not understand is why there is such a message occur.
  1. How should we know? You haven't posted your indicator's code.
  2. See How to do your lookbacks correctly.
Frika
30
Frika 2017.03.01 17:23  
whroeder1:
  1. How should we know? You haven't posted your indicator's code.
  2. See How to do your lookbacks correctly.

I wish I could post the code of the indicator, but I´m not the owner so I have to ask first.

But what I not understood was the fact that the indicator runs in multiple way in a lot‌ of chars without any issue, but when I try to catch the function with the EA there is somewhere a eye of a needle‌

or‌ whatelse. That the handling is so different. I thought that the indicator is loading one time at the beginning of the initialization of the EA and run like it would loaded normaly in the chart, right?

Mladen Rakic
15628
Mladen Rakic 2017.03.01 18:28  
Frika:

I wish I could post the code of the indicator, but I´m not the owner so I have to ask first.

But what I not understood was the fact that the indicator runs in multiple way in a lot‌ of chars without any issue, but when I try to catch the function with the EA there is somewhere a eye of a needle‌

or‌ whatelse. That the handling is so different. I thought that the indicator is loading one time at the beginning of the initialization of the EA and run like it would loaded normaly in the chart, right?

Check if the parameters passed to the indicator from iCustom() call are correct. Sometimes wrong parameters in iCustom() call can cause that issue
Frika
30
Frika 2017.03.01 22:23  
Mladen Rakic:
Check if the parameters passed to the indicator from iCustom() call are correct. Sometimes wrong parameters in iCustom() call can cause that issue
Tahnks for reply Mladen, but I think the parameters are ok so far. 
Signal = iCustom(NULL,0,indicatorName,0,current);

I had reduced the maxBars in the option Menu of MT4. In Chart and History to 2500. This was made the deal.

But the question still exist. Why do the indicator works without problems if its loaded normally in the chart (15 pairs smultanous) but bring up this error messages when ‌it is load by an EA.

Alain Verleyen
Moderator
30721
Alain Verleyen 2017.03.01 22:50  
Frika:
Tahnks for reply Mladen, but I think the parameters are ok so far. 
Signal = iCustom(NULL,0,indicatorName,0,current);

I had reduced the maxBars in the option Menu of MT4. In Chart and History to 2500. This was made the deal.

But the question still exist. Why do the indicator works without problems if its loaded normally in the chart (15 pairs smultanous) but bring up this error messages when ‌it is load by an EA.

Stanislav Korotky
17883
Stanislav Korotky 2017.03.02 12:41  
To figure out where is a bottleneck you should use a profiler. Unfortunately, you can't use the built-in profiler in your case, because you think that slowdown happens only when the indicator is called via iCustom. As a workaround, you could probably try my profiler class. Embed it both into your EA (to measure iCustom invocation time) and the indicator (to measure some critical lines of code). Set UseGlobalVariables to true to accumulate both statistics in terminal's global varibales. Then you'll probably know which part runs slow.
whroeder1
14480
whroeder1 2017.03.02 15:21  
Frika: I had reduced the maxBars in the option Menu of MT4. In Chart and History to 2500.
Why would you want to delete your history? Can't optimize any more.
To add comments, please log in or register