Close orders by indicator

 
It's been more than a month since I've been busting my head with a small EA robot that works with 2-way crunching. 
It does scalper in the HFT style. It opens quite a lot of orders and does not go through the stoploss: either take-profit 
or through the indicator signal. what I want is to close all the orders by the signal of another indexer - in the Stoichast 
case: If Stoichast above 80% aligns closes all the order. If Stoichast below the 30% line close all orders.

Some of you can help me, ... how to handle open, pending orders and put them in a decision structure type ...
 
wagnerr:
It's been more than a month since I've been busting my head with a small EA robot that works with 2-way crunching. 
It does scalper in the HFT style. It opens quite a lot of orders and does not go through the stoploss: either take-profit 
or through the indicator signal. what I want is to close all the orders by the signal of another indexer - in the Stochastic
case: If Stochastic above 80% aligns closes all orders. If Stochastic below the 30% line close all orders.

Some of you can help me, ... how to handle open, pending orders and put them in a decision structure type ...

MQL5 TUTORIAL - SIMPLE STOCHASTIC OSCILLATOR EA

For limit orders,

MqlTradeRequest   _MqlTradeRequest;
MqlTradeResult    _MqlTradeResult;


void OnTick()
  {
   _MqlTradeRequest.symbol       = _Symbol;
   _MqlTradeRequest.action       = TRADE_ACTION_PENDING;
   _MqlTradeRequest.type_time    = ORDER_TIME_GTC;
   _MqlTradeRequest.type_filling = ORDER_FILLING_RETURN;
   _MqlTradeRequest.price        = SymbolInfoDouble(_Symbol,SYMBOL_BID);
   _MqlTradeRequest.volume       = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   _MqlTradeRequest.type         = ORDER_TYPE_BUY_LIMIT;
   if(!OrderSend(_MqlTradeRequest,_MqlTradeResult)) PrintFormat("OrderSend error %d",GetLastError());
  }
Reason: