Thank you very much. I understand your logic, I wouldn´t though about it.

But it doesn´t enter any trade, even if I limit int i to 10, even to 3, to make sure it should enterLong.

As I understand:
1.- Every new bar flag is true
2.- If any (the last 100 bars) priceC<mySMA200 flag would be false, so next condition if(flag) would never be true, so no trade is opened.
3. But if priceC>mySMA200 (all last 100 bars), flag would continue being true so it should enterLong, but it doesn´t. Why??

What´s wrong??