Problem using iCustom in EA

 

Hi All , I'm trying to figure out why when I use some indicator like Support and Resistance Barry's indicator in an EA , the strategy tester is unusable due to slowly.
The EA is something like this :

int start() 
{ 
 // Variables 
 double Support,Resistance; 
 
 // Import Support e Resistance from Barry's indicator
 Resistance = iCustom(NULL,0,"Support and Resistance (Barry)",0,0); 
 Support = iCustom(NULL,0,"Support and Resistance (Barry)",1,0); 
 
 ...
 
}

where the Barry indicator doesn't get any external parameters.
The Barry indicator is quite simple and is like this :

//+------------------------------------------------------------------+
//|                Support and Resistance                            |
//|                Copyright © 2004  Barry Stander                   |
//|                http://myweb.absa.co.za/stander/4meta/            |
//+------------------------------------------------------------------+
#property copyright "Click here: Barry Stander"
#property link      "http://myweb.absa.co.za/stander/4meta/"
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
 
//---- buffers
double v1[];
double v2[];
double val1;
double val2;
int i;
  
int init()
  {
 
  IndicatorBuffers(2);
 
//---- drawing settings
 SetIndexArrow(0, 119);
 SetIndexArrow(1, 119);
  
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT,0,Red);
   SetIndexDrawBegin(0,i-1);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0,"Resistance");
    
 
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,0,Green);
   SetIndexDrawBegin(1,i-1);
   SetIndexBuffer(1, v2);
   SetIndexLabel(1,"Support");
 
   return(0);
  }
 
int start()
  {
  
   i=Bars;
   while(i>=0)
     {
   
val1 = iFractals(NULL, 0, MODE_UPPER,i);
 if (val1 > 0) 
   v1[i]=High[i];
    else
      v1[i] = v1[i+1];
  
val2 = iFractals(NULL, 0, MODE_LOWER,i);
 if (val2 > 0) 
   v2[i]=Low[i];
      else
      v2[i] = v2[i+1];
 
      i--;
     }    
   Comment("\nLatest resistance : ",v1[0],
          "\nLatest support : ",v2[0]);
   return(0);          
  }

So when I backtest the EA , it's really slow :(
May be the problem arise to the huge Bars calculation that EA and indicator have to be for each tick ?
I did experience the same problem with FXSniper's Ergodic CCI & Trigger indicator that get a some 'for' cycle on Bars.
Is there a way to fix this issue ??

Thx a lot :)

Skyline


 
your indicator calculates fractals for every bar every time. You need to indicator_count() function or limit calculation to a reasonalbe number of bars, say i=100.
 
...and even so iCustom is quite slow, I'm guessing it's doing some sort of dll load/unload.
 
Thx irusoh1 & Craig for your reply :) And what about coding dll ? Is there some tutorial on how I can do that and use into my EA ? thx again :) Warmest Regards, Skyline
 
Also remove the Comment lines it will be faster.
/*   Comment("\nLatest resistance : ",v1[0],
          "\nLatest support : ",v2[0]);   */
 

glicci,

There is a real possibility to increase performance of mql4 code with using dll.

Reason: