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.
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; }
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](/i/community/logo_mql5_small.png)
- www.mql5.com
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;
In case your interested, here is how I solved my issue.
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 ®](/i/code/indicator.png)
- votes: 14
- 2010.01.26
- MetaQuotes Software Corp.
- www.mql5.com
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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
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