Please I need a code that could close all open trades and delete all pending orders when equity >= 1.002Initial balance

 
Great day to all traders.

I am a new trader trying to build the simplest code that would place 2 simultaneous orders (Buy stop and Sell Stop) per every take profit fulfilled on a multiple currency transactions till a certain condition (eg. Equity >=1.002 Initial Balance) is met. More profits to your accounts.

Thanks.
Ayo
 
See this sample

//+------------------------------------------------------------------+
//|                                         CloseOrdersOnGainPercent |
//|                                                       MetaQuotes |
//|                                        https://www.metaquotes.net/ru/ |
//+------------------------------------------------------------------+
#property copyright "MetaQuotes"
#property link      "https://www.metaquotes.net/ru/"
 
extern double Ratio=1.02;//
 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
   {
//----
   if (AccountEquity()/AccountBalance()>Ratio) closeOrders();
//----
   return;   
   }
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int closeOrders()
  {
//----
   // проверим тип счета, и если это не демо счет выдадим предупрежение
   // и закончим работу скрипта
   if (!IsDemo()) {Alert("На реальном счете работа запрещена"); return;}
   
   int total=OrdersTotal(); // количество ордеров  
   int ordertype;// тип  ордера   
   if (total==0) {Alert("Нет ордеров для закрытия/удаления");return;}
   int ticket; // будем записывать сюда номер тикета
   double priceClose;// цена, по которой будем закрывать открытые ордера
   for(int i=total-1;i>=0;i--)
      {
      if (OrderSelect(i,SELECT_BY_POS))
         {
         ordertype=OrderType();
         ticket=OrderTicket();
         switch(ordertype)
            {
            case 0:
               // закроем покупку 
               //получим цену Bid по символу
               priceClose=MarketInfo(OrderSymbol(),MODE_BID);
               Print("Закрываем на ",i," позиции ордер с тикетом №",ticket);
               OrderClose(ticket,OrderLots(),priceClose,3,Red);
               break;// выход из блока switch    
            case 1:
               // закроем продажу
               //получим цену Ask по символу
               priceClose=MarketInfo(OrderSymbol(),MODE_ASK);
               Print("Закрываем на ",i," позиции ордер с тикетом №",ticket);
               OrderClose(ticket,OrderLots(),priceClose,3,Red);
               break;// выход из блока switch    
            default:
               // значение от 2 до 5, удаляем отложенный ордер
               Print("Удаляем на ",i," позиции ордер с тикетом №",ticket);
               OrderDelete(ticket);  
               break;// выход из блока switch    
            }    
         }
         
      }   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Rosh, Thanks. Please i would appreciate if you could translate your code and write them in English because I can't understand the language and besides, my client terminal is built on English Language and it would not compile. Thanks.
Reason: