Download MetaTrader 5
To add comments, please log in or register
Share the links to products and make your profit
Oleg Shenker
8430
Oleg Shenker 2016.10.27 18:00 
    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
30298
Alain Verleyen 2016.10.27 21:01  
You should use the Russian forum.
Oleg Shenker
8430
Oleg Shenker 2016.10.27 21:12  
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
13453
Mladen Rakic 2016.10.28 13:06  
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