get the current open position open price and profit - mql5

 

Hello,

 

i need a simple code by simple steps to get the current open position open price and profit using mql5 

 

thanks, 

 

waiting for help :) 

 

is it that hard to look up in the docs?

AccountInfoDouble

Returns the value of the corresponding account property.

double  AccountInfoDouble(
   int  property_id      // identifier of the property
   );

Parameters

property_id

[in]  Identifier of the property. The value can be one of the values of ENUM_ACCOUNT_INFO_DOUBLE.

Return Value

Value of double type.

Example:

void OnStart()
  {
//--- show all the information available from the function AccountInfoDouble()
   printf("ACCOUNT_BALANCE =  %G",AccountInfoDouble(ACCOUNT_BALANCE));
   printf("ACCOUNT_CREDIT =  %G",AccountInfoDouble(ACCOUNT_CREDIT));
   printf("ACCOUNT_PROFIT =  %G",AccountInfoDouble(ACCOUNT_PROFIT));
   printf("ACCOUNT_EQUITY =  %G",AccountInfoDouble(ACCOUNT_EQUITY));
   printf("ACCOUNT_MARGIN =  %G",AccountInfoDouble(ACCOUNT_MARGIN));
   printf("ACCOUNT_FREEMARGIN =  %G",AccountInfoDouble(ACCOUNT_FREEMARGIN));
   printf("ACCOUNT_MARGIN_LEVEL =  %G",AccountInfoDouble(ACCOUNT_MARGIN_LEVEL));
   printf("ACCOUNT_MARGIN_SO_CALL = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL));
   printf("ACCOUNT_MARGIN_SO_SO = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_SO));
  }

or do you want order profit?

OrderGetDouble

Returns the requested property of an order, pre-selected using OrderGetTicket or OrderSelect. The order property must be of the double type.

double  OrderGetDouble(
   ENUM_ORDER_PROPERTY_DOUBLE  property_id        // Property identifier
   );

1. Immediately returns the property value.

2. Returns true or false, depending on the success of a function. If successful, the value of the property is placed in a target variable passed by reference by the last parameter.

For functions OrderGetDouble() and HistoryOrderGetDouble()

ENUM_ORDER_PROPERTY_DOUBLE

Identifier

Description

Type

ORDER_VOLUME_INITIAL

Order initial volume

double

ORDER_VOLUME_CURRENT

Order current volume

double

ORDER_PRICE_OPEN

Price specified in the order

double

ORDER_SL

Stop Loss value

double

ORDER_TP

Take Profit value

double

ORDER_PRICE_CURRENT

The current price of the order symbol

double

ORDER_PRICE_STOPLIMIT

The Limit order price for the StopLimit order

double

 
Mohamed Adel:

Hello,

 

i need a simple code by simple steps to get the current open position open price and profit using mql5 

 

thanks, 

Check you first post, there is a green link, click on it and you will get your answer.
 
  MqlTradeRequest   request;
  MqlTradeResult    result;
  ZeroMemory(request);
  ZeroMemory(result);

  //prepare the order
   request.action = TRADE_ACTION_DEAL
   ...
  ...
 //Send the order
 bool sent = OrderSend(request,result);
 //if return code is successful
 ...
 ulong     posTicketNumber = result.order;
 PositionSelectByTicket(posTicketNumber);
 double positionOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN);
 double  positionCurrentProfit = PositionGetDouble(POSITION_PROFIT);

 


The initial message is old but this is for new searches made on this topic