Download MetaTrader 5

PositionGetSymbol - empty string

To add comments, please log in or register
Oleg Shenker
22983
Oleg Shenker  
    positions = PositionsTotal();
    if(positions == 0) return(true);
    for(int i=0; i < positions; i++)//for every position open
      {
       position_symbol = PositionGetSymbol(i);
       ticket = PositionGetInteger(POSITION_TICKET);

Три открытых позиции. PositionsTotal() возвращает три.

При переборе в цикле при i = 2, PositionGetSymbol(i) возвращает пустую строку.

Почему он не находит позицию? 

При проверке возвращает наличие ошибки 4753 "Позиция не найдена".

Alain Verleyen
Moderator
33486
Alain Verleyen  
You should use the Russian forum.
Oleg Shenker
22983
Oleg Shenker  
Alain Verleyen:
You should use the Russian forum.

I though I use Russian.

I saw you have answered similar question several time. I get error 4753 in the third loop of cycle (i = 2). 

Mladen Rakic
62840
Mladen Rakic  
Oleg Shenker:

I though I use Russian.

I saw you have answered similar question several time. I get error 4753 in the third loop of cycle (i = 2). 

Are you doing something to the position in the rest of the code?

Since this loop :

   string position_symbol = "";
      if (PositionsTotal() == 0) return(true);
         ResetLastError();
         for(int i=PositionsTotal()-1; i>=0 && GetLastError()==0; i--)
            position_symbol += PositionGetSymbol(i)+"\n";
        
      Comment(position_symbol+"\nLast error : "+(string)GetLastError());

causes no error (regardless of how many positions are currently opened)

To add comments, please log in or register