One should never prematurely exit a for(open_trades) loop prematurely without using the break_trades macro. Otherwise, you will see lots of strange side effects that will ruin your trading algorithm.

So basically, the function needs to be re-written. Something like this (untested):
Code
bool findTrade(var Price,var Grid,bool IsShort) 
{
  bool out = false;
  for(open_trades)
    if((TradeIsShort == IsShort)
      and between(TradeEntryLimit,Price-Grid/2,Price+Grid/2)){
        out = true;
        break_trades;
      }
  return out;
}

Last edited by AndrewAMD; 04/25/21 18:40. Reason: rev1 - fixed code