array out of range error in backtesting

 

when I put the EA or predictor in the backtesting, there always pop out array out of range error like the following, I donot whether it's my error or the config of the ea.

for example the first ea is from Deep neural network with Stacked RBM. Self-training, self-control

the number of k lines cannot exceed 100 when I test it in EA, It always crash when variable i goes up to 100

      for(i = 0; i < lim; i++)

      {

         Print("lim:"+lim+"i:"+i);

         o[i]  = Open[i+1];

         hi[i] = High[i+1];

         lo[i] = Low[i+1];

         clo[i]= Close[i+1];


      }

below is the log, is there sth that I missed?

1 21:25:36.646 TestGenerator: unmatched data error (volume limit 2630 at 2017.10.04 15:00 exceeded)

1 21:25:36.646 TestGenerator: unmatched data error (volume limit 2630 at 2017.10.04 15:00 exceeded)

1 21:25:36.646 TestGenerator: unmatched data error (volume limit 2630 at 2017.10.04 15:00 exceeded)

2 21:25:36.709 1970.01.01 00:00:00  e_DNSAE inputs: Lots=0.1; TakeProfit=50; StopLoss=45; magic=654321; cor=3; n=34; z=37; soft=1; Kmin=10; limit=1000; 

0 21:25:37.398 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: 1

0 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: lim:1000i:0

0 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: lim:1000i:1

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

0 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: lim:1000i:100

1 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: array out of range in 'e_DNSAE.mq4' (143,22)

3 21:25:37.409 2017.05.17 10:00:00  Testing pass stopped due to a critical error in the EA

0 21:25:37.409 AUDCHF,H1: 1 tick events (2466 bars, 8359005 bar states) processed in 0:00:00.703 (total time 0:00:45.469)


the second ea performs the same thing, I backtest the EA from https://www.mql5.com/zh/code/15782

the same thing happened that array out of range

is there sth that I missed?

1 01:38:40.826 TestGenerator: unmatched data error (low value 147.69300 at 2017.10.12 13:06 and price 147.69000 mismatched)

1 01:38:40.826 TestGenerator: unmatched data error (high value 147.81400 at 2017.10.12 13:05 is not reached from the least timeframe, high price 147.80800 mismatches)

1 01:38:40.826 TestGenerator: unmatched data error (low value 147.64800 at 2017.10.12 13:11 and price 147.64700 mismatched)

1 01:38:40.826 TestGenerator: unmatched data error (low value 147.64800 at 2017.10.12 13:12 and price 147.64300 mismatched)

1 01:38:40.842 TestGenerator: 139 generating errors, logged 100 first error records

0 01:38:40.932 Custom indicator YJ64GUA GBPJPY,M5: loaded successfully

2 01:38:40.932 YJ64GUA test started

1 01:38:41.182 2017.10.12 00:00:00  YJ64GUA GBPJPY,M5: array out of range in 'YJ64GUA.mq4' (249,18)

3 01:38:41.253 2017.10.12 00:00:00  Testing pass stopped due to a critical error in the EA

0 01:38:41.253 2017.10.12 00:00:00  GBPJPY,M5: 2 tick events (1236 bars, 113720 bar states) processed in 0:00:00.329 (total time 0:00:00.485)

易经64卦
易经64卦
  • votes: 9
  • 2017.02.17
  • fxgainer
  • www.mql5.com
根据中国古老的预测方法"易经"编写的指标。断线代表阴:即closeopen的蜡烛。 在窗口上方显示从"坤"卦到"姤"卦的32个卦象;在窗口下方显示从"复"到"乾"卦的32个卦象。 在窗口的左侧显示当前蜡烛所对应的卦名及卦的解释说明,并在窗口上方或下方以红色显示当前蜡烛对应的卦象。 指标运行在M5时间框架,对K线的每个蜡烛标注了对应的卦名。
 
vxgu86:

when I put the EA or predictor in the backtesting, there always pop out array out of range error like the following, I donot whether it's my error or the config of the ea.

for example the first ea is from Deep neural network with Stacked RBM. Self-training, self-control

the number of k lines cannot exceed 100 when I test it in EA, It always crash when variable i goes up to 100

      for(i = 0; i < lim; i++)

      {

         Print("lim:"+lim+"i:"+i);

         o[i]  = Open[i+1];

         hi[i] = High[i+1];

         lo[i] = Low[i+1];

         clo[i]= Close[i+1];


      }

below is the log, is there sth that I missed?

1 21:25:36.646 TestGenerator: unmatched data error (volume limit 2630 at 2017.10.04 15:00 exceeded)

1 21:25:36.646 TestGenerator: unmatched data error (volume limit 2630 at 2017.10.04 15:00 exceeded)

1 21:25:36.646 TestGenerator: unmatched data error (volume limit 2630 at 2017.10.04 15:00 exceeded)

2 21:25:36.709 1970.01.01 00:00:00  e_DNSAE inputs: Lots=0.1; TakeProfit=50; StopLoss=45; magic=654321; cor=3; n=34; z=37; soft=1; Kmin=10; limit=1000; 

0 21:25:37.398 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: 1

0 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: lim:1000i:0

0 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: lim:1000i:1

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

0 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: lim:1000i:100

1 21:25:37.409 2017.05.17 10:00:00  e_DNSAE AUDCHF,H1: array out of range in 'e_DNSAE.mq4' (143,22)

3 21:25:37.409 2017.05.17 10:00:00  Testing pass stopped due to a critical error in the EA

0 21:25:37.409 AUDCHF,H1: 1 tick events (2466 bars, 8359005 bar states) processed in 0:00:00.703 (total time 0:00:45.469)


the second ea performs the same thing, I backtest the EA from https://www.mql5.com/zh/code/15782

the same thing happened that array out of range

is there sth that I missed?

1 01:38:40.826 TestGenerator: unmatched data error (low value 147.69300 at 2017.10.12 13:06 and price 147.69000 mismatched)

1 01:38:40.826 TestGenerator: unmatched data error (high value 147.81400 at 2017.10.12 13:05 is not reached from the least timeframe, high price 147.80800 mismatches)

1 01:38:40.826 TestGenerator: unmatched data error (low value 147.64800 at 2017.10.12 13:11 and price 147.64700 mismatched)

1 01:38:40.826 TestGenerator: unmatched data error (low value 147.64800 at 2017.10.12 13:12 and price 147.64300 mismatched)

1 01:38:40.842 TestGenerator: 139 generating errors, logged 100 first error records

0 01:38:40.932 Custom indicator YJ64GUA GBPJPY,M5: loaded successfully

2 01:38:40.932 YJ64GUA test started

1 01:38:41.182 2017.10.12 00:00:00  YJ64GUA GBPJPY,M5: array out of range in 'YJ64GUA.mq4' (249,18)

3 01:38:41.253 2017.10.12 00:00:00  Testing pass stopped due to a critical error in the EA

0 01:38:41.253 2017.10.12 00:00:00  GBPJPY,M5: 2 tick events (1236 bars, 113720 bar states) processed in 0:00:00.329 (total time 0:00:00.485)

for(i = 0; i < lim-1; i++)
 
nicholishen:

No not this one

the lim is 1000 and i is stopped at 100 in backtesting.

lim:1000   i:100

I have temporily solved this by making the tester only process small number bars in OnCalculate and the second indictor's problem is solved. I will try the first one later

int OnCalculate(const int rates_total,...

  {


   if(rates_total<=atrPeriod || atrPeriod<=0)

      return(0);

   int limit=rates_total-prev_calculated;

   if(prev_calculated>0)

      limit++;

   if(limit>barsToProcess)

      limit=barsToProcess;  

 

vxgu86 array out of range error like the following, I donot whether it's my error or the config of the ea.

the number of k lines cannot exceed 100 when I test it in EA, It always crash when variable i goes up to 100

      for(i = 0; i < lim; i++){

         Print("lim:"+lim+"i:"+i);
         o[i]  = Open[i+1];
  1. When you post code please use the SRC button! Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. It is your error. Lim can not be smaller than the size of o[] nor smaller than Bars (Rates_Total.) Post all the relevant code (lim,) and relevant variables (Bars.)
 
whroeder1:
  1. When you post code please use the SRC button! Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. It is your error. Lim can not be smaller than the size of o[] nor smaller than Bars (Rates_Total.) Post all the relevant code (lim,) and relevant variables (Bars.)

sorry about that. 

my question is common in two eas with the same error. the indicator is running good but when I put it in the tester, the error is poped.

Now I have solved the second one with solution that,  limit the barsToProcess as 15 bars

maybe there are some limits in EA that the bars to process is limited?

I will try the solution in the first ea

   int limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit++;
   if(limit>barsToProcess)
      limit=barsToProcess;  
   for(int i=0; i<limit; i++)
   {
      buf1[i]=iMA(NULL,0,atrPeriod,0,MODE_LWMA,PRICE_MEDIAN,i);
      if(Close[i]>buf1[i])//=================error===============
      {
            printf("shift is :"+i);
            y2=Low[i]-ATR/2;
            y1=Low[i];
      }
   }
 
vxgu86:

sorry about that. 

my question is common in two eas with the same error. the indicator is running good but when I put it in the tester, the error is poped.

Now I have solved the second one with solution that,  limit the barsToProcess as 15 bars

maybe there are some limits in EA that the bars to process is limited?

I will try the solution in the first ea

Mt4 tester starts with number of bars set (and generated) to 100. Mt5 is slightly better (but just slightly :))

Always compare that limit to the actual number of bars (check it on monthly charts and you shall have that error on regular charts too if you do not check the limit compared to the actual number of bars)

 

Hello,

We are only dealing with requests related to financial operations on mql5.com. All other questions/requests should be posted on the forum.

Best regards,
MQL5.com Support Team

 
Do your lookbacks correctly. For the posted code it is atrPeriod.