calculate profit in pips

 

Hi can somebody tell me how i calculate the profit in pips in the history trades?because i wrote this but when i check the profit is 110$ and it show 0.0473.?


<CODE REMOVED>

 
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
 
ok thanks
 
double pipsmultiplier;
void init()
{
 if(MarketInfo(Symbol(),MODE_DIGITS)==3 && MarketInfo(Symbol(),MODE_DIGITS)==5)
 {
  pipsmultiplier=10;
 }
 else
 {
  pipsmultiplier=1; 
 }
}
void start()
{
 getprofit();
}

void getprofit()
    {
     double profits;
     for (int i=OrdersHistoryTotal() -1; i >= 0; i--) 
       { 
       if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true){
        if(OrderSymbol()==Symbol())
           if(OrderType() == OP_BUY || OrderType() == OP_SELL)
               {               
                profits += OrderProfit()+OrderSwap()+OrderCommission();
               } 
        }       
       }  
       double prof=NormalizeDouble((profits)/(pipsmultiplier)*MarketInfo(Symbol(),MODE_POINT),8);                      
       Print("net profit",prof);
    } 
 

Hmm first of all in your Init() you need to change your && to ||.

Secondly you can not simply divide your profit by point to tell you how many pips you made.

You are not taking into consideration the size of a trade.

100.00 made on a 1 lot trade is only 10 pips.

100.00 made on a .01 lot trade is 1000 pips.

That assumes you are trading something that ends in USD like EURUSD, GBPUSD, AUDUSD.

If it is USDJPY or GBPCHF you have some more math to do. Have fun..

PipPip..Jimdandy.

p.s. putting (profits) and (pipsmultiplier) in their own parentheses accomplishes nothing.

maybe you meant (profits/pipsmultiplier)?

 
hi sir thanks for your reply but i am not understand i need to use this code for all currency and it give wrong result to me can you tell me more about that?
 
ankitkalindi:
hi sir thanks for your reply but i am not understand i need to use this code for all currency and it give wrong result to me can you tell me more about that?

Profit in Points is the difference between the entry price and the exit price, it has nothing to do with the $ profit from a trade
 

ok forget the dollar now can you tell me the problem in the code i mean how to find the total profit in my history trades ?

 

hi can somebody tell me what is my error at below code because as i ma not able to find it?

 
ankitkalindi:

hi can somebody tell me what is my error at below code because as i ma not able to find it?


There is no code below your post
 
double pipsmultiplier;
void init()
{
 if(MarketInfo(Symbol(),MODE_DIGITS)==3 && MarketInfo(Symbol(),MODE_DIGITS)==5)
 {
  pipsmultiplier=10;
 }
 else
 {
  pipsmultiplier=1; 
 }
}
void start()
{
 getprofit();
}

void getprofit()
    {
     double profits;
     for (int i=OrdersHistoryTotal() -1; i >= 0; i--) 
       { 
       if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true){
        if(OrderSymbol()==Symbol())
           if(OrderType() == OP_BUY || OrderType() == OP_SELL)
               {               
                profits += OrderProfit()+OrderSwap()+OrderCommission();
               } 
        }       
       }  
       double prof=NormalizeDouble((profits)/(pipsmultiplier)*MarketInfo(Symbol(),MODE_POINT),8);                      
       Print("net profit",prof);
    } 
Reason: