Download MetaTrader 5

get the current open position open price and profit - mql5

To add comments, please log in or register
Mohamed Adel
124
Mohamed Adel 2015.08.01 17:27 

Hello,

 

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

 

thanks, 

Mohamed Adel
124
Mohamed Adel 2015.08.03 17:21  

waiting for help :) 

Marco vd Heijden
Moderator
4731
Marco vd Heijden 2015.08.03 18:53  

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

Alain Verleyen
Moderator
31090
Alain Verleyen 2015.08.04 15:10  
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.
To add comments, please log in or register