please help (mql5 function-strategy tester)

 
image (function 01)-how I wrote the code
image (tester 01 - tester011) mt5 strategy tester - I can't make a good calculation between (profit + swap)

It always calculates some negative value for me, regardless of whether the position is positive.


thank you!!!!!



           function code !!!

long NajveciDobitakF(string comment)                            
   {  
      long TickeNumber=0;
      double ProfitTicket=0;                                       
      uint OpenOrder = PositionsTotal ();        
      for(uint i=0;i<OpenOrder;i++)                
         {
         long PPM = PositionGetInteger(POSITION_MAGIC);
         string PPS = PositionGetString (POSITION_COMMENT);      
         double DProfit = PositionGetDouble (POSITION_PROFIT);
         double DSwap = PositionGetDouble (POSITION_SWAP);           
         long PPTicket = PositionGetInteger(POSITION_TICKET);
         double Racunica11 =(DProfit+DSwap);
         printf (DProfit);
         Comment (Racunica11); 
         if ( PPM == ExpertMG || PPS == comment )
            {                                            
               if (Racunica11>ProfitTicket)
                  {
                     TickeNumber=PPTicket;
                     ProfitTicket=Racunica11;
                     
                  }
            
            
            }
            
         }
   return TickeNumber;              
   }
The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
Files:
function_01.png  98 kb
tester_01.png  56 kb
tester011.png  66 kb
 

Don't post images of your code.

Please edit your post and copy and paste your code using the code button (Alt+S).

 
Keith Watford:

Don't post images of your code.

Please edit your post and copy and paste your code using the code button (Alt+S).

I copy-paste the code on the post..