EA runs slow on one platform but other EAs run fast.

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
1109
Ovo 2015.06.22 10:00 #
 
Ruptor:
Please read my last post guys where I have reached a conclusion that shows a quirk in the MT4 interpreter when running. My inefficient code shows the problem but it shouldn't create it or be there in the first place. Is it because I only have 2GB that it occurs?
It could be the reason, MT4 memory requirements have increased a lot with 800+ builds.
avatar
12985
WHRoeder 2015.06.22 13:10 #
 

Ruptor:
By editing the indicator so it only goes back a couple of bars further than period of the longest MA it uses the EA now runs very fast.
What doesn't make sense is that the trigger that makes the EA go slow does not change the number of times the indicator is called it just does a bit of extra code when in a trade.
In normal operation on a live chart I know the indicator code only uses the latest tick and does not load all the bars but in a backtest it can't work like that because it is reloaded on every call. Therefore indicators have to be specially written for use in EAs so they only load the bars they need.

  1. That means your indicator was recalculating every bar instead of just the new one. Do it right:
    int counted = IndicatorCounted();
    int lookBack= ... ; // your maximum lookback MA(p)=p-1 Close[i+2]=2 ...
    for(int iBar = Bars - 1 - MathMax(counted, lookBack); iBar >= 0; --iBar){
  2. Your EA does not call an indicator ("indicator is called") your EA only reads out of the indicator's buffer - do that however much you want, no calculating is done. The Indicator is called per tick, before the EA gets called.
  3. The indicator is not reloaded on every call, it is loaded once. There is no need for "specially written" indicators. #1
  4. Sounds like toward the end you have more volume, and your indicator runs more. #1
avatar
453
Ruptor 2015.06.24 00:30 #
 
WHRoeder:
  1. That means your indicator was recalculating every bar instead of just the new one. Do it right:
  2. Your EA does not call an indicator ("indicator is called") your EA only reads out of the indicator's buffer - do that however much you want, no calculating is done. The Indicator is called per tick, before the EA gets called.
  3. The indicator is not reloaded on every call, it is loaded once. There is no need for "specially written" indicators. #1
  4. Sounds like toward the end you have more volume, and your indicator runs more. #1

WHR I am confused now and still nothing about how the problem occurs makes sense. Yes it looks like the indicator is loading all bars but I have fixed that in my own way and it solves the problem. However are you saying that iCustom called inside an EA never happens after the first call? The question still stands as to why does the code only go slow when I select to use my own trailing stop that doesn't have anything to do with the only call of iCustom in the code that makes the trade decision? If the indicator does go reload all bars on every tick wouldn't it redraw the chart every time? I thought the indicator was correct because it uses the standard example code and it doesn't slow my platform when it is put on a chart. Here is the bar calculation part of the indicator that must have a problem but I can't see it.

   cbars=IndicatorCounted();
   if (Bars<=(periodAMA+2)) return(0);
//---- check for possible errors
   if (cbars<0) return(-1);
//---- last counted bar will be recounted
   if (cbars>0) cbars--;
   pos=Bars-cbars+periodAMA+2;
   AMA0=Open[pos+1];
   while (pos>=0){

     .......etc......
  
     pos--;
   }

avatar
12985
WHRoeder 2015.06.24 03:19 #
 
  1. if (cbars>0) cbars--;
    Means it is recalculating bar one and zero every tick Contradictory information on IndicatorCounted() - MQL4 forum
  2. pos=Bars-cbars+periodAMA+2;
    means it is recalculating periodAMA+1 through bar zero every tick.
  3. AMA0=Open[pos+1];
    Means your lookback is one. Fix your loop properly.
  4. However are you saying that iCustom called inside an EA never happens after the first call?
    I never said anything about you iCustom call(s)
  5. If the indicator does go reload all bars on every tick wouldn't it redraw the chart every time?
    And if it recalculates the same values, how would you know?
avatar
453
Ruptor 2015.06.24 13:55 #
 
Thanks for your help but none of the these faults would cause the indicator to load more and more data to make the EA get slower as the back test progresses. Therefore I have to assume the iCustom call reloads the indicator with the ever increasing bars as the back test progresses especially since my modified indicator that loads a fixed number of bars has fixed the problem.
Back to topics list   | 1 2  

To add comments, please log in or register