Problem with concatenated For Loops New comment Will404 2013.07.11 22:31 Hi,I've got trouble concatenating For Loops, this is the nearest previous step that doesn't give me trouble:#define f 20*10 int h = 0; char ar1[f]; char ar2[f]; int OnInit() { //--- for(char i=0;i<20;i++){ for(char j=0;j<10;j++){ ar1[h]=i+1; ar2[h]=j+1; Print(h+" "+ar1[h]); h++; } } //--- return(INIT_SUCCEEDED); } The Print gives a nice progression of h: 1,2,3,4,5.. and the expected result for ar1[h]:1,1,1,1,1,1,1,1,1,1,2,2,2,2.. ...20,20,20. But, if I try to do this:#define f 20*10*5 int h = 0; char ar1[f]; char ar2[f]; char ar3[f]; int OnInit() { //--- for(char i=0;i<20;i++){ for(char j=0;j<10;j++){ for(char k=0;j<5;k++){ ar1[h]=i+1; ar2[h]=j+1; ar3[h]=k+1; Print(h+" "+ar1[h]); h++; } } } //--- return(INIT_SUCCEEDED); } The Print of ar1[h] just give 1,1,1,1,1,1,1... ...1,1,1 until it gets out of range (the print of h goes from 1,2,3,4... to ..998,999).Isn't it possible to concatenate 3 For Loops? What am I doing wrong? Documentation on MQL5: MQL5 programs / Runtime Errors www.mql5.com MQL5 programs / Runtime Errors - Documentation on MQL5 Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes Problems checking for open trade For loop in an EA Alain Verleyen 2013.07.11 22:56 #1 Will404:...Isn't it possible to concatenate 3 For Loops? What am I doing wrong? for(char i=0;i<20;i++){ for(char j=0;j<10;j++){ for(char k=0;j<5;k++){ ar1[h]=i+1; ar2[h]=j+1; ar3[h]=k+1; Print(h+" "+ar1[h]); h++; } } }You mixed j and k. Will404 2013.07.11 23:41 #2 angevoyageur: You mixed j and k.Ok, thanks.. New comment
Hi,
I've got trouble concatenating For Loops, this is the nearest previous step that doesn't give me trouble:
The Print gives a nice progression of h: 1,2,3,4,5.. and the expected result for ar1[h]:1,1,1,1,1,1,1,1,1,1,2,2,2,2.. ...20,20,20. But, if I try to do this:
The Print of ar1[h] just give 1,1,1,1,1,1,1... ...1,1,1 until it gets out of range (the print of h goes from 1,2,3,4... to ..998,999).
Isn't it possible to concatenate 3 For Loops? What am I doing wrong?