Executing trades within a price range

 

I'm quite new to MQL and have trouble figuring this out. The current code I have keeps on spamming orders. Am I doing something wrong?


   for(int i=0;i<10;i++){  
      if(closeprice>=prend[i] && closeprice<=prstart[i]){
            Buy();
            break;
}
     
Reason: