Multiple calls of iCustom on backtest with more than one pair

 
Hi all! 

I'm trying to do A backtest of an EA with more than one pair. In this case I use a custom indicator via iCustom and every time I call the handle the indicator is added to the chart and I end up with the same indicator 100 times.

This does not happens in the regular EA. Any idea of why this might happens?

My idea is not to use this, but to know how it performs in a portfolio with X amounts of pairs.

This is the way I am coding the EA. 

int getDamiani(string symbol)
  {
   damianiHandle=iCustom(symbol,timeFrame,"Damiani_Volatmeter 2018",InpViscosity,InpAtrSedimentation,InpStdViscosity,InpSedimentation,Threshold_level);

   ArraySetAsSeries(damianiBuffGreen,true);
   ArraySetAsSeries(damianiBuffRed,true);

   CopyBuffer(damianiHandle,0,0,3,damianiBuffGreen);
   CopyBuffer(damianiHandle,1,0,3,damianiBuffRed);
   bool trade=true;
   for(int i=0;i<voltBarsToValid;i++)
     {
      if(damianiBuffGreen[i]<=damianiBuffRed[i])
        {
         trade=false;
         break;
        }
     }
   if(trade)
     {
      return 1;
     }
   return 0;
  }

So, what happens is that on every tick, there is a function like this:

input string symb1 = "EURCAD"
input string symb2 = "EURUSD"

checkTrade(0,symb1);
checkTrade(1,symb2);

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void checkTrade(int i,string symbol)
  {
   if(tradesOpen[i]>0)
     {
      string auxCheckTradeType=checkTradeType(symbol);

      ZeroMemory(lastTick);
      SymbolInfoTick(symbol,lastTick);
      if((auxCheckTradeType=="buy" && lastTick.bid>=takeProfit[i]) || (auxCheckTradeType=="sell" && lastTick.ask<=takeProfit[i])) trailing(auxCheckTradeType,symbol,i);
     }
   else
     {
      takeProfit[i]=0;
      firstCall[i]=true;

      validVolume=getVolume(symbol);
      DSP=getDSP(symbol);
      trend=getTrend(symbol);
      damiani=getDamiani(symbol);
      Spread=(int)SymbolInfoInteger(symbol,SYMBOL_SPREAD);

      if(validVolume==0 || damiani==0 || Spread>spread)
        {
         return;
        }
      if(DSP==1 && trend==1) //buy
        {
         openTrade(1,symbol,i);
        }

      if(DSP==2 && trend==-1) //sell
        {
         openTrade(-1,symbol,i);
        }
     }

  }

Why this happens with iCustom but with other indicators (like iATR) it doesn't?

 
thanks
 
Pedro Severin:
Hi all! 

I'm trying to do A backtest of an EA with more than one pair. In this case I use a custom indicator via iCustom and every time I call the handle the indicator is added to the chart and I end up with the same indicator 100 times.

This does not happens in the regular EA. Any idea of why this might happens?

My idea is not to use this, but to know how it performs in a portfolio with X amounts of pairs.

This is the way I am coding the EA. 

So, what happens is that on every tick, there is a function like this:

Why this happens with iCustom but with other indicators (like iATR) it doesn't?

Because the parameters you are passing to iCustom are incorrect in some way.
Reason: