我正在尝试以下代码:
void OnInit()
{
int i = 0;
string d[];
while(i < 2)
{
ArraySetAsSeries(d,true);
for (int j=0; j<5; j++)
{
if(MathMod(j,2)==0 && i==0)
d[j] = "even";
else if(MathMod(j,2)==0 )
d[j] = "even without i zero";
else
d[j] = "odd";
}
i++;
}
}
我愿意在测试中获得输出。但我收到以下错误:
2018.03.23 14:51:20.005 EURUSD,M1(MetaQuotes-Demo):基于真实生成
ticks
2018.03.23 14:51:20.006 EURUSD,M1: testing of Experts\testing lines and trdae.ex5 from 2018.02.01 00:00 to 2018.02.20 00:00 started
2018.03.23 14:51:20.050 2018.02.01 00:00:00 array out of range in 'testing lines and trdae.mq5' (61,2)
2018.03.23 14:51:20.051 OnInit critical error
请帮助我摆脱这个并打印阵列,因为我愿意打印它。
答案 0 :(得分:0)
You must explicitely indicate the size of the array before inserting data into it.
Use ArrayResize(d,5);
and then it will work.