Looping problem, return values=0

 

Hi there community, I'm trying to get Symbol Profit values from the loop. Made this way:

      double TotalProfit=0;
      int LongPos=0,ShortPos=0;
      double SProfit=0,SLoss=0;
      double Positive=0,Negative=0;
      for(int i=0;i<PositionsTotal();i++){
         ulong Ticket=PositionGetTicket(i);
         double PosProfit=PositionGetDouble(POSITION_PROFIT);
         if(PositionGetString(POSITION_SYMBOL)==SName){SProfit+=PosProfit;
            if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY){LongPos++;}
            if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL){ShortPos++;}}
         if(SProfit>0){SProfit=SProfit;Positive++;}
         else{SLoss=SProfit;Negative++;}
         TotalProfit+=PosProfit;}

Print result is throwing value 0 almost every time:

SProfit: 0.0, SLoss: 0.0

HigherProfit: 0.0

SProfit: 0.62, SLoss: 0.0

HigherProfit: 0.62

SProfit: 0.0, SLoss: 0.0

HigherProfit: 0.0

SProfit: 0.0, SLoss: 0.0

HigherProfit: 0.0

...

How is this possible?


 
It would help if you provide complete code which compiles - i.e. include the declaration/setting of Sname and also the print statement you are using. 
 

The main loop checks through all market watch symbols:

   for(int s=0;s<SymbolsTotal(true);s++){
      string SName=SymbolName(s,true);

The internal loop intends to filter only by traded symbols, print values are the following:

Print("SProfit: ",SProfit,", SLoss: ",SLoss);

Any help on this matter is welcome.

 
No help from me. On my Do Not Help List
David Diez           220211   388657#comment_27652887       argumentative
                     210607   370848#comment_22737037       argumentative
                     190921   322656#comment_13288449       argumentative 2 DNH
                     190513   318861/page2#comment_12618331 argumentative 5 DNH
 
William Roeder #:
No help from me. On my Do Not Help List
David Diez           220211   388657#comment_27652887       argumentative
                     210607   370848#comment_22737037       argumentative
                     190921   322656#comment_13288449       argumentative 2 DNH
                     190513   318861/page2#comment_12618331 argumentative 5 DNH
If you are not willing to help, please keep away.
Reason: