Download MetaTrader 5
To add comments, please log in or register
Share links from other resources. Now they have a description.
John May
3724
John May 2013.01.30 20:01 

I am trying to make a quick conversion of the current position profit to pips with this line of code:

 

#include <Trade\Trade.mqh>        //include the library for execution of trades
CPositionInfo     m_Position;        // entity for obtaining information on positions
int  PIP_SWAG;            // Buy/Sell PIP Tolerance
if(MathAbs(m_Position.Profit()/SymbolInfoDouble(my_symbol,SYMBOL_TRADE_TICK_VALUE))<PIP_SWAG)

 Where m_Position is using the Trade class object.

The issue I am having is that over different installations of meta trader 5 terminals (I mean I have one that is a FXCM-MT5 Demo and another that is a Metaquotes Demo), the relationship between m_Position.Profit and the variable SYMBOL_TRADE_TICK_VALUE varies by a factor of 10, which I did not expect. Would any of you have a cleaner way to make this conversion? I appreciate your consideration

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
Andrey Barinov
39197
Andrey Barinov 2013.01.30 20:46  
CappinJack:

I am trying to make a quick conversion of the current position profit to pips with this line of code:

 

 Where m_Position is using the Trade class object.

The issue I am having is that over different installations of meta trader 5 terminals (I mean I have one that is a FXCM-MT5 Demo and another that is a Metaquotes Demo), the relationship between m_Position.Profit and the variable SYMBOL_TRADE_TICK_VALUE varies by a factor of 10, which I did not expect. Would any of you have a cleaner way to make this conversion? I appreciate your consideration

 

Hi, you can use the difference between current price and Position Open price, to calculate the profit/loss in pips. It is a bit more reliable and easier than the way you described.


enbo lu
Moderator
1904
enbo lu 2013.01.31 02:53  

I think you mean that some brokers are using five digits price while others using four digits. 

      double point = MarketInfo(OrderSymbol(),MODE_POINT);
      double tick_value = SymbolInfoDouble(my_symbol,SYMBOL_TRADE_TICK_VALUE);
      if(point==0.00001 || point==0.001)
         {            
                      tick_value = tick_value*10;       
         }   
John May
3724
John May 2013.01.31 22:13  
luenbo:

I think you mean that some brokers are using five digits price while others using four digits. 

That is true, however in this case they are both using 5 digits. I think I am going to change up and just use the position open price versus the current price as suggested.

But is something I will dig into the future.

thanks for the comments. 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
John May
3724
John May 2013.02.03 03:21  
CappinJack:

That is true, however in this case they are both using 5 digits. I think I am going to change up and just use the position open price versus the current price as suggested.

But is something I will dig into the future.

thanks for the comments. 

In case your interested, here is how I solved my issue.

         if(MathAbs(m_Position.PriceOpen()-m_Position.PriceCurrent())<PIP_SWAG*SymbolInfoDouble(my_symbol,SYMBOL_POINT)) return;

 

phi nuts
2184
phi nuts 2013.02.03 06:30  
CappinJack:

In case your interested, here is how I solved my issue.

 

Thank you for sharing, but what is PIP_SWAG ?
John May
3724
John May 2013.02.03 19:40  
phi.nuts:
Thank you for sharing, but what is PIP_SWAG ?
phi.nuts
:

Thank you for sharing, but what is PIP_SWAG ?

PIP_SWAG is an input variable 

In this particular case I am checking if a position has moved more than a pre-detirmined amount of points ( PIP_SWAG ) since it opened.

phi nuts
2184
phi nuts 2013.02.03 23:25  
CappinJack:

PIP_SWAG is an input variable 

In this particular case I am checking if a position has moved more than a pre-detirmined amount of points ( PIP_SWAG ) since it opened.

OK, thank you for the explanation :)

Its better to make it automatic like for example using levels of Bollinger band.

Bollinger Bands ®
Bollinger Bands ®
  • votes: 14
  • 2010.01.26
  • MetaQuotes Software Corp.
  • www.mql5.com
The Bollinger Bands ® Indicator (BB) is similar to Envelopes. The only difference is that the bands of Envelopes are plotted a fixed distance (%) away from the moving average, while the Bollinger Bands are plotted a certain number of standard deviations away from it.
khai hoan nguyen
242
khai hoan nguyen 2013.02.08 04:05  
I think to convert from pips to profit is more need . so you nedd study how to calculate value one pip in some different pairs currency.
/
To add comments, please log in or register