NEED Help!! How to make limit order per condition >,< - page 2

 
Richmond Chikotolo #: can some one help me the EA keeps telling me maximum allowe opened order reached

Don't double post! You already had another thread open.

          General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)
 
Richmond Chikotolo #:

can some one help me the EA keeps telling me maximum allowe opened order reached

void OnTick() {
   if(isNewCandle()) {
      int signal = getDataFromBuffers();
      if(limitOpenOrders() <= limitOrders) {
         if(signal == OP_BUY) {
            openBuy();
            useTrailingStop();
         }
         if(signal == OP_SELL) {
            openSell();
            useTrailingStop();
         } else {
            Print("Maximum Allowed Opened Orders Limit is Reached !!!");
         }
      }
   }
}

      if(limitOpenOrders() <= limitOrders)

Assuming that your function returns correct values and your variable has the correct value......

it should not be <= because if orders are = limit, one more will exceed the limit.

Also note that some brokers will not have a value set for the limit, so you need to check for this.

if(limitOrders==0 || limitOpenOrders() < limitOrders)


I have deleted your duplicate topic.