Profit to pips

 

Hi,

 

how can I convert order profit to pips?

Asuming I know lotsize etc.

 I want to create trailing stop, but profit oriented. 

 

Thanks. 

 
On most of the USD-accounts 1 pip of a trade with 1 lot has the value of 10,- USD - start from that?
 
Pesoxx: how can I convert order profit to pips?
pips = profit / PipValuePerLot
gooly: On most of the USD-accounts 1 pip of a trade with 1 lot has the value of 10,- USD - start from that?
What do you do if the account is NOT USD or if the traded pair doesn't end in USD?
 

Gooly: Exactly how WHRoeder said, I need something universal.

WHRoeder: Thanks, I'll try it. 

 
Pesoxx:

Gooly: Exactly how WHRoeder said, I need something universal.

WHRoeder: Thanks, I'll try it. 

double PriceToPips(double price) 
{
   double pips;
   if(Symbol()=="SPI200")  {pips = price*1;   return(NormalizeDouble(pips,1));}    
   if(Symbol()=="DAX30")   {pips = price*1;  return(NormalizeDouble(pips,1));}
   if(Symbol()=="S&P")     {pips = price*1;   return(NormalizeDouble(pips,1));}   
   if(Symbol()=="WTI")     {pips = price*10;  return(NormalizeDouble(pips,2));}   
   if(Digits == 0) {pips = price*1;      return(NormalizeDouble(pips,1));} 
   if(Digits == 1) {pips = price*1;      return(NormalizeDouble(pips,1));}  
   if(Digits == 2) {pips = price*10;     return(NormalizeDouble(pips,1));}   //JPY pairs
   if(Digits == 3) {pips = price*100;    return(NormalizeDouble(pips,1));}   
   if(Digits == 4) {pips = price*10000 ; return(NormalizeDouble(pips,1));}  //
   if(Digits == 5) {pips = price*10000;  return(NormalizeDouble(pips,1));}
   return(0);
}
 
WHRoeder:
Pesoxx: how can I convert order profit to pips?
pips = profit / PipValuePerLot
gooly: On most of the USD-accounts 1 pip of a trade with 1 lot has the value of 10,- USD - start from that?
What do you do if the account is NOT USD or if the traded pair doesn't end in USD?

WHRoeder: we already had this discussion: what will you do if you want to trade non-Forex symbols like DAX30, Bonds, Oil, .. or if e.g. a broker's XAUUSD has one more digit?
 
gooly: WHRoeder: we already had this discussion: what will you do if you want to trade non-Forex symbols like DAX30, Bonds, Oil, .. or if e.g. a broker's XAUUSD has one more digit?
  1. Pesoxx: how can I convert order profit to pips?
    If you're not trading Forex, the question makes no sense.
  2. When a broker goes to 1/100 PIP. I'll go with pip2dbl= StringFind("JPY", _symbol) < 0 ? 0.0001 : 0.01;
 
WHRoeder:
  1. Pesoxx: how can I convert order profit to pips?
    If you're not trading Forex, the question makes no sense.
  2. When a broker goes to 1/100 PIP. I'll go with pip2dbl= StringFind("JPY", _symbol) < 0 ? 0.0001 : 0.01;

It does make sense and it is required if for example you want to trade non-symbols that the brokers offers with an EA that has been developed on various forex symbols.

The brokers do offer more and more non forex-symbols like bonds, commodities, index-shares, even single shares - do we have to ignore them, because they are not 'forex' and we have an meaningless definition for a pip?

On the other hand we can easily renew the definition of a pip as the nearest value to (USD-account) 10-USD for a 1-lot order - the same you get for pure forex symbols.

Due to this definition it doesn't matter which symbol you are trading or how many digits a symbol has, a Stop of 10 pips will always risk ~100 USD of a 1 lot order. 

If your account currency is not USD, you can change the the reference value (refValue) but e.g. for EUR you'll get the same 'pip-size' but in EUR 1 pip is now ~8,62 EUR - even in your calculation WHRoeder

Of course for an JPY-Account 10  might not be the correct refValue.

 
gooly:

It does make sense and it is required if for example you want to trade non-symbols that the brokers offers with an EA that has been developed on various forex symbols.

The brokers do offer more and more non forex-symbols like bonds, commodities, index-shares, even single shares - do we have to ignore them, because they are not 'forex' and we have an meaningless definition for a pip?

On the other hand we can easily renew the definition of a pip as the nearest value to (USD-account) 10-USD for a 1-lot order - the same you get for pure forex symbols.

Due to this definition it doesn't matter which symbol you are trading or how many digits a symbol has, a Stop of 10 pips will always risk ~100 USD of a 1 lot order. 

If your account currency is not USD, you can change the the reference value (refValue) but e.g. for EUR you'll get the same 'pip-size' but in EUR 1 pip is now ~8,62 EUR - even in your calculation WHRoeder

Of course for an JPY-Account 10  might not be the correct refValue.


 

If you are using "foreign" code or coding for others, you can NEVER rely on a "definition" of a pip. Even with Forex it's not always clear for everyone, though it's simple, but with all other symbols you have to agree on a definition before doing anything else.

If you code for yourself, it doesn't matter apply any definition which is better for you.

 
angevoyageur:

If you are using "foreign" code or coding for others, you can NEVER rely on a "definition" of a pip. Even with Forex it's not always clear for everyone, though it's simple, but with all other symbols you have to agree on a definition before doing anything else.

If you code for yourself, it doesn't matter apply any definition which is better for you.

Well the expression pip is widely used and due to the symbol expansion of the brokers in the recent years (if I am correct the original forex symbols has become a 'minority' with some brokers!) the original understanding of a pip has become in such a context rather absurd. So to be able to continue to talk about stops and targets measured in pips one has to find a new definition the covers all that new 'stuff' including the original definition.

Otherwise you are trapped in a way that you have to define singleton pips per broker and symbol and may by per account-currency. (I hate this idea, as this is so error-prone due to the manual input.)

 
o calculate your profits and losses in pips to your native currency, you must convert the pip value to your native currency.

When you close a trade, the profit or loss is initially expressed in the pip value of the quote currency. To determine the total profit or loss, you must multiply the pip difference between the open price and closing price by the number of units of currency traded. This yields the total pip difference between the opening and closing transaction.

If the pip value is in your native currency, then no further calculations are needed to find your profit or loss, but if the pip value is not in your native currency, then it must be converted. There are several ways to convert your profit or loss from the quote currency to your native currency. If you have a currency quote where your native currency is the base currency, then you divide the pip value by the exchange rate; if the other currency is the base currency, then you multiply the pip value by the exchange rate.
Reason: