新手写自定义指标的问题

 

各位大神好。我的指标

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   Alert("======  indicator strar: "+TimeLocal()+"    ======");
   Alert("rates_total: "+rates_total);
   int bars;
   bars=rates_total-prev_calculated;
   if(prev_calculated>0) bars++;
   Alert("bars: "+bars);
   for(int i=0;i<bars;i++)
   {
      CopyHigh(Symbol(),0,i,count,high10);
      CopyLow(Symbol(),0,i,count,low10);
      ArraySort(high10,WHOLE_ARRAY,0,MODE_DESCEND);
      ArraySort(low10);
      high10Buffer[i]=high10[13];
      //Alert("["+i+"]-high10[13]= "+high10[13]);
      if(GetLastError()>0)
      {
         Alert("GetLastError("+i+") Code is: "+GetLastError());
         break;
      }
      low10Buffer[i]=low10[13];
   }
   Alert("======  indicator stop: "+TimeLocal()+"    ======");
//--- return value of prev_calculated for next call
   return(rates_total);
  }
test-indicatior-000 XAUUSD,H1: array out of range in 'test-indicatior-000.mq4' (72,29)
test-indicatior-000 XAUUSD,H1: Alert: bars: 114359
test-indicatior-000 XAUUSD,H1: Alert: rates_total: 114359
test-indicatior-000 XAUUSD,H1: Alert: ======  indicator strar: 2024.03.04 13:22:33    ======

报的错误我用GetLastError获取不到,请高手帮忙看看如何解决。

另外这个指标执行非常慢,我估计跟上面的报错有关系,报错处理完,执行速度可能就正常了。


万分感谢!


 
array out of range in 'test-indicatior-000.mq4' (72,29)

數組超出範圍 ==> 數組的設定錯誤

原因: