Can´t get active positions count on mql5

To add comments, please log in or register
Valerio Fuiorea
36
Valerio Fuiorea  

I can´t get te number of active positions. It counts +1 for every tick while position is open. How can i do it?

Please. Thanks a lot.





for(int i=0;i<PositionsTotal();i++) // Go through all positions
     
   if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
   if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
      {  
         if(m_position.PositionType()==POSITION_TYPE_BUY)
         TotalBuy+=1;
         Comment(TotalBuy);     
               
         if(m_position.PositionType()==POSITION_TYPE_SELL)
         TotalSell+=1;
         Comment(TotalSell);
      } 
Amir Yacoby
1223
Amir Yacoby  

Add initialization before for loop:

TotalBuy=0;
TotalSell=0;
Valerio Fuiorea
36
Valerio Fuiorea  
Amir Yacoby:

Add initialization before for loop:

Already done... i don'd get why is conting by ticks and not by each position...
Valerio Fuiorea
36
Valerio Fuiorea  
Amir Yacoby:

Add initialization before for loop:

OK SOLVED. Thx there was another line in the middle thats why!!!! You helped me!!! THX

To add comments, please log in or register