Mql4 to mql5 простой советник

Эксперты

Техническое задание

Нужна конвертация простенького советника mql4 в mql5

#include <stdlib.mqh>

extern int Magic = 1;
extern double Lots = 0.1;

extern bool Tral = true;
extern int TrailingStopLoss = 30;
extern double Utral = 150;
extern bool Sound = true;

int slippage = 3;
static int prevtime = 0;

double FirstPositionPrice;

int order_MgcNum=0, err=0, ticket=0, res;
bool result = True;
double MyPoint;  

int init()
{
 if (Digits == 5 || Digits == 3)
  {
TrailingStopLoss=TrailingStopLoss*10;
  }
  return(0);
 }

int start() {
if (Tral) TrailingPositions(TrailingStopLoss, 1, Magic);

int total,cnt,pos,order;
string order_comment = Symbol()+", Period "+Period()+", ADX  "+Magic;

//if (Volume[0]>5) return(0);

double i1 = iADX(Symbol(),0,13,0,MODE_PLUSDI,0);
double i2 = iADX(Symbol(),0,13,0,MODE_MINUSDI,0);

if  (i1<i2) {
if(CheckExists(OP_SELL))   { 
    total=OrdersTotal(); pos=0;
    for (cnt=0;cnt<total;cnt++) {
        OrderSelect(cnt, SELECT_BY_POS);
        if ((OrderSymbol() == Symbol())&&(OrderMagicNumber()==Magic)) {
            order=OrderTicket(); pos=1;
            if (IsTradeAllowed() && (OrderType() == OP_BUY)) { 
               RefreshRates();// Новые Аск и Бид
               result = OrderClose(order,Lots,Bid,3);
               if (result)OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,order_comment,Magic,0,Red);
               if (!result) {
                  err=GetLastError();
                  } return(0);
               }
            }
        }
    if ((pos==0) && IsTradeAllowed()) {
        RefreshRates();// открытие с рынка
         res=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,order_comment,Magic,0,Red);
         if (res<0) {Alert("Ошибка открытия ордера SELL #", GetLastError()); return (0);}              
         return(0);
        }
    }
   }
if  (i1>i2) {
if(CheckExists(OP_BUY))   { 
    total=OrdersTotal(); pos=0;
    for (cnt=0;cnt<total;cnt++) {
        OrderSelect(cnt, SELECT_BY_POS );
        if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == Magic)) {
            order=OrderTicket(); pos=1;
            if (IsTradeAllowed()&& (OrderType() == OP_SELL)) {
               RefreshRates();// Новые Аск и Бид
               result = OrderClose(order,Lots,Ask,3);
               if(result)OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,order_comment,Magic,0,Lime);
               if(!result){
                  err=GetLastError();
                  } return(0);
               }
            }
        }
    if ((pos==0) && IsTradeAllowed()) {
        RefreshRates();// открытие с рынка
         res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,order_comment,Magic,0,Lime);
         if (res<0) {Alert("Ошибка открытия ордера BUY #", GetLastError()); return (0);}              
         return(0);
        }
    }
   }
return(0);
}
//---------------------------------------------------------------------------------+
void TrailingPositions(int trailingStopLoss, int trailingStep, int MagicNumber) {
   double bid = 0;
   double ask = 0;
   double X=1;

   for (int i = 0; i < OrdersTotal(); i++) {
      if (!(OrderSelect(i, SELECT_BY_POS)) || OrderSymbol() != Symbol() ) {
         continue;
      }
      
      bid = MarketInfo(OrderSymbol(), MODE_BID);
      ask = MarketInfo(OrderSymbol(), MODE_ASK);
      
      
      if (OrderType() == OP_BUY&&Bid-OrderOpenPrice()<Utral*Point&&OrderMagicNumber() == MagicNumber) {
         if (bid - OrderOpenPrice() > X*trailingStopLoss * Point) {
            if (OrderStopLoss() < bid - (X*trailingStopLoss + trailingStep - 1) * Point || OrderStopLoss() == 0) {
               OrderModify(OrderTicket(), OrderOpenPrice(), bid - X*trailingStopLoss * Point, OrderTakeProfit(), OrderExpiration(),Aqua);
               if(Sound == true)PlaySound("ok.wav");
            }
         }
      } else if (OrderType() == OP_SELL&&OrderOpenPrice()-Ask<Utral*Point&&OrderMagicNumber() == MagicNumber) {
         if (OrderOpenPrice() - ask > X*trailingStopLoss * Point) {
            if (OrderStopLoss() > ask + (X*trailingStopLoss + trailingStep - 1) * Point || OrderStopLoss() == 0) {            
               OrderModify(OrderTicket(), OrderOpenPrice(), ask + X*trailingStopLoss * Point, OrderTakeProfit(), OrderExpiration(),Aqua);
               if(Sound == true)PlaySound("ok.wav");
            }
         }
      }
   }

}
  
bool CheckExists(int Type)
 {
  bool Result = True;
  for(int i = 0; i < OrdersTotal(); i++)
   if(OrderSelect(i, SELECT_BY_POS))
    if(OrderType() == Type && OrderMagicNumber() == Magic && OrderSymbol() == Symbol())
     if(OrderOpenTime() >= Time[0])
      Result = False;
  for(i = 0; i < OrdersHistoryTotal(); i++)
   {
    if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
     if(OrderType() == Type && OrderOpenTime() >= Time[0] 
        && OrderMagicNumber() == Magic && OrderSymbol() == Symbol())
      Result = False;
    }    
      
  return(Result);    
  }

Откликнулись

1
Разработчик 1
Оценка
(111)
Проекты
327
55%
Арбитраж
17
12% / 47%
Просрочено
104
32%
Свободен
2
Разработчик 2
Оценка
(187)
Проекты
367
56%
Арбитраж
45
22% / 56%
Просрочено
188
51%
Свободен
Опубликовал: 1 статью, 6 примеров
3
Разработчик 3
Оценка
(4)
Проекты
8
13%
Арбитраж
1
0% / 0%
Просрочено
0
Свободен
Опубликовал: 2 примера
Похожие заказы
Подобные решения уже есть в интернете, написаны в виде советника. Из их минусов - разработчики советника предоставляют котировки около 50 торговых пар. Мне необходимо, чтобы в мт5 поступали котировки абсолютно всех торговых пар. Ссылку на подобный советник могу предоставить, как на ориентир, образец
Советник 200+ USD
Советник по мартингейлу на хеджевых счетах на МТ5 Торгуем рыночными ордерами. Торговая панель средней сложности. Более конкретное ТЗ вышлю всем заинтересовавшимся. Оплата и сроки обсуждаемы. Нужен советник по индикатору Во вложении ТЗ. все значения переменные

Информация о проекте

Бюджет
10- USD
Сроки выполнения
до 5 дн.