Please Please help with calculating netpip movement !

To add comments, please log in or register
prweza
427
prweza  

Hi all,

I have created this function that sums up net pip movements for buy  and sell orders but it  does not seem to work properly. Basically  for example, the ea opens a buy order at   81.50 and now the pair has moved 81.70. the net pip movement is 0.20. then the same ea sells the same pair at 81.50 and  the pair has moved to  81.60. the net pip movement is -0.10. Now the net pip movements for the 2 positions is 0.20+ -0.10 =  0.10.

What is wrong with my code?

double NetPips()

  {
   
    double PASK=MarketInfo(NULL,MODE_ASK);
   double PBID=MarketInfo(NULL,MODE_BID);
   double ORP=OrderOpenPrice();
  
   
   double SumBuyP=0;
   double SumSellP=0;

   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)

         // match the symbol EUR/USD or EUR/CHF, etc
         if(OrderSymbol()==Symbol())
           {
            if(OrderType()==OP_BUY)
               SumBuyP+=PASK-ORP;
            if(OrderType()==OP_SELL)
               SumSellP+=PBID-ORP;
               
       
           }

     }
   return( SumBuyP+SumSellP);
     }
  


ith my code below?

To add comments, please log in or register