← Назад к списку файлов

average_5363996961055735987.mq4

Поиск по коду файла

#property version   "1.00"
#property strict
enum ENUM_AVERAGE_TYPE
  {
   All      = 0,
   OnlyBuy  = 1,
   OnlySell = 2
  };

input ENUM_AVERAGE_TYPE iTypeAverage = All;
input int               iProfiPlus   = 600;
input int               iMagicNumber = -1;

int OnInit()
  {
      // код доступен только после оплаты
   }

void OnTick()
  {
      // код доступен только после оплаты
   }

   int total = OrdersTotal();

   double BuySummPrice = 0, BuySummLots = 0;
   double SelSummPrice = 0, SelSummLots = 0;
   double Average = 0;

   for(int i = 0; i < total; i++)
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         if(OrderSymbol() == _Symbol)
            if(OrderMagicNumber() == iMagicNumber || iMagicNumber == -1)
              {
               if(OrderType() == OP_BUY)
                 {
                  BuySummPrice += OrderOpenPrice() * OrderLots();
                  BuySummLots  += OrderLots();
                 }
               if(OrderType() == OP_SELL)
                 {
                  SelSummPrice += OrderOpenPrice() * OrderLots();
                  SelSummLots  += OrderLots();
                 }
              }

   if((BuySummLots - SelSummLots) != 0)
     {
      if(iTypeAverage == All)
        {
         if(BuySummLots > SelSummLots)
            Average = (BuySummPrice - SelSummPrice) / (BuySummLots - SelSummLots) + iProfiPlus * _Point;

         if(BuySummLots < SelSummLots)
            Average = (BuySummPrice - SelSummPrice) / (BuySummLots - SelSummLots) - iProfiPlus * _Point;
        }

      if(iTypeAverage == OnlyBuy)
         Average = BuySummPrice / BuySummLots + iProfiPlus * _Point;

      if(iTypeAverage == OnlySell)
         Average =  SelSummPrice / SelSummLots - iProfiPlus * _Point;
     }

   for(int i = 0; i < total; i++)
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         if(OrderSymbol() == _Symbol)
            if(OrderMagicNumber() == iMagicNumber || iMagicNumber == -1)
              {
               if(OrderType() == OP_BUY)
                 {
                  if(iTypeAverage == OnlyBuy)
                     if(Bid < Average)
                        if(OrderTakeProfit() != Average)
              

Показано первые 50% кода (символов: 2392)

Как получить полную версию?

Введите ваш email и нажмите кнопку, чтобы перейти к оплате.