Скачать MetaTrader 5
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Опубликуй статью. Получи вознаграждение!
Vladislav Andruschenko
83105
Vladislav Andruschenko 2014.04.09 13:22 

всем привет,

есть код модификации позиций:

//+------------------------------------------------------------------+
void Modify(string symToWork2,int sl2,int tp2)
//+------------------------------------------------------------------+
  {


Print(symToWork2);

      if(PositionSelect(symToWork2))
        {

         if((PositionGetString(POSITION_SYMBOL)!=symToWork2)) return;

         order_open_price = PositionGetDouble(POSITION_PRICE_OPEN);
         order_type       = PositionGetInteger(POSITION_TYPE);
         request.order    = PositionGetInteger(POSITION_IDENTIFIER);

         if(order_type==POSITION_TYPE_BUY)
           {

            double sl,tp;

            if(sl2!=0 ) sl=SymbolInfoDouble(symToWork2,SYMBOL_BID)-sl2*SymbolInfoDouble(symToWork2,SYMBOL_POINT); else sl=0;
            if(tp2!=0 ) tp=SymbolInfoDouble(symToWork2,SYMBOL_BID)+tp2*SymbolInfoDouble(symToWork2,SYMBOL_POINT); else tp=0;


            request.action=TRADE_ACTION_SLTP;
            request.symbol= symToWork2;
            if( sl!=PositionGetDouble(POSITION_SL))request.sl     = sl;else request.sl=PositionGetDouble(POSITION_SL);
            if( tp!=PositionGetDouble(POSITION_TP))request.tp     = tp;else request.tp=PositionGetDouble(POSITION_TP);
            request.deviation=(ulong)((SymbolInfoDouble(symToWork2,SYMBOL_ASK)-SymbolInfoDouble(symToWork2,SYMBOL_BID))/SymbolInfoDouble(symToWork2,SYMBOL_POINT))*2; // по спреду 
            if(request.sl==PositionGetDouble(POSITION_SL) && request.tp==PositionGetDouble(POSITION_TP))return;
OrderSend(request,result);

            if(result.retcode==TRADE_RETCODE_DONE)
              {
               if(Sounds)PlaySound("ok.wav"); Print("Result = "+(string)result.retcode+
                  " symbol "+(string)request.symbol+" volume "+(string)request.volume+" action "+(string)request.action+" tp "+(string)request.tp+" sl "
                  +(string)request.sl+" type "+(string)request.type+" price "+(string)request.price+"   "+ErrorDescription(result.retcode));
              }
            else
              {
               if(Sounds)PlaySound("stops.wav");
               Print("ERROR Result = "+(string)result.retcode+
                     " symbol "+(string)request.symbol+" volume "+(string)request.volume+" action "+(string)request.action+" tp "+(string)request.tp+" sl "
                     +(string)request.sl+" type "+(string)request.type+" price "+(string)request.price+"   "+ErrorDescription(result.retcode));
              }

            return;
           }// end POSITION_TYPE_BUY    

         else if(order_type==POSITION_TYPE_SELL)
           {

            double sl,tp;

            if(sl2!=0) sl=SymbolInfoDouble(symToWork2,SYMBOL_ASK)+sl2*SymbolInfoDouble(symToWork2,SYMBOL_POINT); else sl=0;
            if(tp2!=0) tp=SymbolInfoDouble(symToWork2,SYMBOL_ASK)-tp2*SymbolInfoDouble(symToWork2,SYMBOL_POINT); else tp=0;
            request.action = TRADE_ACTION_SLTP;
            request.symbol = symToWork2;
            if(sl!=PositionGetDouble(POSITION_SL))request.sl     = sl;else request.sl=PositionGetDouble(POSITION_SL);
            if(tp!=PositionGetDouble(POSITION_TP))request.tp     = tp;else request.tp=PositionGetDouble(POSITION_TP);
            request.deviation=(ulong)((SymbolInfoDouble(symToWork2,SYMBOL_ASK)-SymbolInfoDouble(symToWork2,SYMBOL_BID))/SymbolInfoDouble(symToWork2,SYMBOL_POINT))*2; // по спреду 
            if(request.sl==PositionGetDouble(POSITION_SL) && request.tp==PositionGetDouble(POSITION_TP))return;

            OrderSend(request,result);
            if(result.retcode==TRADE_RETCODE_DONE)
              {
               if(Sounds)PlaySound("ok.wav"); Print("Result = "+(string)result.retcode+
                  " symbol "+(string)request.symbol+" volume "+(string)request.volume+" action "+(string)request.action+" tp "+(string)request.tp+" sl "
                  +(string)request.sl+" type "+(string)request.type+" price "+(string)request.price+"   "+ErrorDescription(result.retcode));
              }
            else
              {
               if(Sounds)PlaySound("stops.wav");
               Print("Result = "+(string)result.retcode+
                     " symbol "+(string)request.symbol+" volume "+(string)request.volume+" action "+(string)request.action+" tp "+(string)request.tp+" sl "
                     +(string)request.sl+" type "+(string)request.type+" price "+(string)request.price+"   "+ErrorDescription(result.retcode));
              }

           }// end POSITION_TYPE_SELL

        }// end if select                

  Print( GetLastError());
  }

на обычных счетах все работает

на счетах где есть буква суфикс, напрмиер EURUSD.m - не хочет выбирать позицию

пишет ошибку позиция не найдена:

2014.04.09 16:25:23.680	Exp - The X (UniversalEA + Averager) (EURCHF.m,M1)	Result = 10009 symbol EURCHF.m volume 0.01 action 1 tp 0 sl 0 type 0 price 1.21766   TRADE_RETCODE_DONE Заявка выполнена
2014.04.09 16:25:23.679	Exp - The X (UniversalEA + Averager) (EURCHF.m,M1)	4753
2014.04.09 16:25:23.679	Exp - The X (UniversalEA + Averager) (EURCHF.m,M1)	EURCHF.m

Vladislav Andruschenko
83105
Vladislav Andruschenko 2014.04.09 13:23  
кто знает где трабла?
Victor Nikolaev
Модератор
14079
Victor Nikolaev 2014.04.09 13:28  
Vladon:
кто знает где трабла?

Похоже к разработчикам надо
Vladislav Andruschenko
83105
Vladislav Andruschenko 2014.04.09 17:24  
Vinin:

Похоже к разработчикам надо

спасибо
/
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий