New to mql, new problem :(

Hi,
I have been learning mql4 for few months. It’s a uphill battle!.
I have a “seem to be so simple” problem but I spend the whole after trying to solve it, but fail!.
This code below with 2 separate FOR() but it only how the first buffers.
(for the illustration purpose, I dont use if else).

Any help is much appreciated.

UBFX

  int limit=rates_total-prev_calculated;

//FIRST FOR()
for(int i=1;i<=limit; i++)
{ if(Close[i]<Open[i])
{ buy[i]=Open[i];}
}

//SECOND FOR()
for(int j=1;j<=limit;j++)
{ if(Close[j]>Open[j])
{sell[j]=Close[j];}
}

//— return value of prev_calculated for next call

return(rates_total);

}