/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "GoldenSheva"
#property link      ""

#property indicator_chart_window

extern int Buy_MaxTrades = 10;
extern int Sell_MaxTrades = 10;
string gs_dummy_84;

int init() {
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int l_ind_counted_0 = IndicatorCounted();
   Information();
   return (0);
}

void Information() {
   Comment("" + "                              PROVERKA " + Symbol() 
      + "\n" 
      + "                              ------------------------------------------------" 
      + "\n" 
      + "                              Брокер: " + AccountCompany() + ". Плечо: 1:" + DoubleToStr(AccountLeverage(), 0) 
      + "\n" 
      + "                              ------------------------------------------------" 
      + "\n" 
      + "                              ПОКУПКА " + CountTrades("buy") + " из " + Buy_MaxTrades 
      + "\n" 
      + "                              Баланс по текущим позициям: " + DoubleToStr(Balance("buy", "Balance"), 2) 
      + "\n" 
      + "                              Суммарный лот: " + DoubleToStr(Balance("buy", "Lot"), 2) 
      + "\n" 
      + "                              ------------------------------------------------" 
      + "\n" 
      + "                              ПРОДАЖА " + CountTrades("sell") + " из " + Sell_MaxTrades 
      + "\n" 
      + "                              Баланс по текущим позициям: " + DoubleToStr(Balance("sell", "Balance"), 2) 
      + "\n" 
      + "                              Суммарный лот: " + DoubleToStr(Balance("sell", "Lot"), 2) 
      + "\n" 
      + "                              ------------------------------------------------" 
      + "\n" 
   + "                              Общий баланс по всем позициям: " + DoubleToStr(Balance("buy", "Balance") + Balance("sell", "Balance"), 2));
}

double Balance(string as_0, string as_8) {
   double ld_ret_16 = 0;
   for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) {
      OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol()) {
         if (OrderSymbol() == Symbol()) {
            if (as_0 == "buy") {
               if (OrderType() == OP_BUY) {
                  if (as_8 == "Balance") ld_ret_16 = ld_ret_16 + OrderProfit() - OrderSwap() - OrderCommission();
                  if (as_8 == "Lot") ld_ret_16 += OrderLots();
               }
            }
            if (as_0 == "sell") {
               if (OrderType() == OP_SELL) {
                  if (as_8 == "Balance") ld_ret_16 = ld_ret_16 + OrderProfit() - OrderSwap() - OrderCommission();
                  if (as_8 == "Lot") ld_ret_16 += OrderLots();
               }
            }
         }
      }
   }
   return (ld_ret_16);
}

int CountTrades(string as_0) {
   int l_count_8 = 0;
   for (int l_pos_12 = OrdersTotal() - 1; l_pos_12 >= 0; l_pos_12--) {
      OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol()) {
         if (OrderSymbol() == Symbol()) {
            if (as_0 == "buy")
               if (OrderType() == OP_BUY) l_count_8++;
            if (as_0 == "sell")
               if (OrderType() == OP_SELL) l_count_8++;
         }
      }
   }
   return (l_count_8);
}
