mt5 and the in the exchange execution i m facing very weird problem

 

i m using mt5 and the in the exchange execution i m facing very weird problem. can any one see the issue in my code

it make in and out in and out 2 or times to close the position

void CloseTradesifNoVolume(string symbol ,double &volume[] ,string &ArrFileSymbol[])
{
double masterbuylots=0; double masterselllots=0 ; double lotforopen=0;
 for(int i=0;i<ArraySize(volume);i++)
    {
    if(ArrFileSymbol[i]==symbol && ordertype_Slave[i]==0)masterbuylots+=volume[i];
    if(ArrFileSymbol[i]==symbol && ordertype_Slave[i]==1)masterselllots+=volume[i];
    }
 
 if(masterbuylots==0 && masterselllots==0)
   {
   for(int i=0;i<=PositionsTotal()-1;i++)
      {
      bool select = info.SelectByIndex(i);
      
      if((info.Magic()==CopierMagic  || info.Magic()>=0) && info.Symbol()==symbol && info.Volume()>0)
        {
       
        trade.PositionClose(info.Ticket());
        
        break;
        }
      }
   }
}


why the inout one more time  ?? does nay one have an idea what i m doing mistake?

 

When closing/deleting, you ALWAYS need to count down :

for(int i=PositionsTotal()-1;i>=0;i--)
 
Alain Verleyen:

When closing/deleting, you ALWAYS need to count down :


ok thank you i will try and give feed back

 
Alain Verleyen:

When closing/deleting, you ALWAYS need to count down :


Still Same Issue??

 
Muhammad Mudasir:

Still Same Issue??

You are trying to close a position twice on a netting account.

Debug your code.

 
Alain Verleyen:

You are trying to close a position twice on a netting account.

Debug your code.


ok thanks i will look up the code