How to - Closed Profit into Pips?

 
I know pips are the difference between OrderOpenPrice and OrderClosePrice.
I also know how to see pips on my chart comments using Ask,Bid, and OrderOpenPrice.

How Can I get the total pips earned and lost from orders I have closed?

Here is code I use to get my closed Profit/Loss:

         closedProfit = 0;                // counts closed p&l


            int total = HistoryTotal();
            for(int i=0;i<total;i++)     // scan all closed / cancelled transactions
              { OrderSelect(i, SELECT_BY_POS, MODE_HISTORY );
              if ( OrderSymbol()==Symbol() && ( (OrderMagicNumber() == MagicNumber)
 { closedProfit = closedProfit + OrderProfit();


              }
             } 



Thank you



 
I will try this. Thank you
 
Slawa here is what I tried. I want closed from Expert only, not all experts, so I make balance = 0.
It works for buy orders but does not seem to work for sells. I am getting mixed results

  closedProfit = 0;                // counts closed p&l
double point_value;
double balance= 0;

            int type = OrderType();
            int total = HistoryTotal();
            for(int i=0;i<total;i++)                                // scan all closed / cancelled transactions
              { OrderSelect(i, SELECT_BY_POS, MODE_HISTORY );
              if ( OrderSymbol()==Symbol() && ( (OrderMagicNumber() == Magic1)
{ closedProfit = closedProfit + OrderProfit();
                point_value=MarketInfo(OrderSymbol(),MODE_POINT);
                      if(point_value==0) continue;
      double open_price=OrderOpenPrice();
      double close_price=OrderClosePrice();
      double profit=(close_price-open_price)/point_value;
      if(type==OP_SELL) profit=-profit;
      balance+=profit;


              }
             } 



If can help, thanks

 
int type = OrderType(); should be inside loop after OrderSelect