Using indicator Slows Down speed of backtesting,Why?

 

Hello Guys, I have Create a simple indicator which shows a moving average on OsMa indicator

everything works fine, but when i want to use it from an EA The backtesting Speed's is too slow

I call it from EA like this

OSMAmain=iCustom(NULL,0,"OsMA_SIGNAL",FastEMA,SlowEMA,SignalSMA,MAPeriod,MAMethod,0,0);
OSMAsignal=iCustom(NULL,0,"OsMA_SIGNAL",FastEMA,SlowEMA,SignalSMA,MAPeriod,MAMethod,1,0);

Why Speed is too slow?

What do you think?

Thanks for Helping



The Code for indicator is below:

//+------------------------------------------------------------------+
//|                                          OsMA With MA Signal.mq4 |
//|                          Copyright © 2010, Farshad Saremifar     |
//|                                                                  |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2010, Farshad Saremifar"
#property  link      ""
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Silver
#property  indicator_width1  2
//colour for signal line
#property  indicator_color2  Red
#property  indicator_width2  1
//---- indicator parameters
extern int FastEMA=50;
extern int SlowEMA=210;
extern int SignalSMA=80;
//external variable for the period of the signal line
extern string MA_MAMethod =  "-------(SMA=0,EMA=1,SMMA=2,LWMA=3)------";                           

extern int MAPeriod = 11;
extern int MAMethod = 0;
//---- indicator buffers
double     OsmaBuffer[];
//we need an additional buffer for the signal line
double     MASignalBuffer[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(2);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,OsmaBuffer);
   SetIndexDrawBegin(0,SignalSMA);
   SetIndexLabel(0,"Osma"); 
    SetIndexStyle(1,DRAW_LINE);
   
   SetIndexDrawBegin(1,MAPeriod);
   SetIndexBuffer(1,MASignalBuffer);
   SetIndexLabel(1,"MA Signal"); 


   
  
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Average of Oscillator                                     |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- osma counted in the 1-st additional buffer
   for(int i=0; i<limit; i++)
      OsmaBuffer[i]=iOsMA(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,i);
//---- ma signal line counted in the 1-st additional buffer

 for( i=0; i<limit; i++)
     MASignalBuffer[i]=iMAOnArray(OsmaBuffer,Bars,MAPeriod,0,MAMethod,i);
   



     
   return(0);
  }
//+------------------------------------------------------------------+
 
kimitrio:

Why Speed is too slow?

What do you think?

More calculations are being done... Why wouldn't it be slower?

 
gordon:

More calculations are being done... Why wouldn't it be slower?

Thanks Gordon for the reply,you are always the one who answers all the problems,you are great man

Do You suggest anything else?I Use this moving average on Osma For signaling,Do you have any other way to use it?with simple calculation??


Thanks

 
kimitrio:

Thanks Gordon for the reply,you are always the one who answers all the problems,you are great man

Do You suggest anything else?I Use this moving average on Osma For signaling,Do you have any other way to use it?with simple calculation??


Thanks

To be honest, my knowledge of indi's is very limited since I don't use any (my experts don't use any technical analysis). Maybe this recent post can give u some ideas: https://www.mql5.com/en/forum/123747.

 
gordon:

To be honest, my knowledge of indi's is very limited since I don't use any (my experts don't use any technical analysis). Maybe this recent post can give u some ideas: https://www.mql5.com/en/forum/123747.

Thanks for Advice and thanks for supporting,I have seen that link before posting this,

The OsMa's self have the same calcuation on Macd but That's Not Slow on Backtesting;

 

The last line is iMAOnArray(..., Bars, ... i)

First, there are not Bars+i available in the array.

Second it isn't necessary to do all Bars. A SMA only requires only period bars, while the EMA requires 3.45(period+1) bars

Reason: