如何在此处处理或处理/避免数组超出范围错误:
for(int i=0; i<=ObjectsTotal()-1; i++)
{
string objName = ObjectName(0,i);
if(StringFind(objName,"Last#")>=0)
{
string tempval= objName;
string temtext= ObjectGetString(0,objName,OBJPROP_TEXT);
StringReplace(tempval,"Last#","");
int tempnum = (int)(tempval);
for(int k=tempnum; k>=tempnum-20; k--)
{
if(
RBuffer1[k] != EMPTY_VALUE)
{
ObjectDelete(0,objName);
DrawText("Last#"+tempnum,Time[tempnum],Low[tempnum],temtext+"_0","Arial",9,clrWhite);
break;
}
else
if(RBuffer2[k] != EMPTY_VALUE)
{
ObjectDelete(0,objName);
DrawText("Last#"+tempnum,Time[tempnum],Low[tempnum],temtext+"_1","Arial",9,clrWhite);
break;
}
}
}
}
我确信我的逻辑有问题,但无法弄清楚到底是什么,并且该指标在某些时间范围内工作正常,但在 2 ,3 时间范围内,它会抛出错误数组超出范围
这是 for(int k=tempnum; k>=tempnum-20; k--)我收到错误的地方。