Download MetaTrader 5

OrderCalcProfit : what's the profit variable ?

To add comments, please log in or register
Searching on MQL5.community is performed in all sections. Try it!
Icham Aidibe
10044
Icham Aidibe 2014.11.20 11:46 

Hi ! 

I don't get it, what's the variable profit for obtaining the profit value ? I thought it was a function that calculate the profit based on the opening, closing price & volume.

bool  OrderCalcProfit(
   ENUM_ORDER_TYPE       action,           // type of the order (ORDER_TYPE_BUY or ORDER_TYPE_SELL)
   string                symbol,           // symbol name
   double                volume,           // volume
   double                price_open,       // open price
   double                price_close,      // close price
   double&               profit            // variable for obtaining the profit value
   );
Irwan Adnan
886
Irwan Adnan 2014.11.20 12:01  
blouf:

Hi ! 

I don't get it, what's the variable profit for obtaining the profit value ? I thought it was a function that calculate the profit based on the opening, closing price & volume.

yes it is.
Icham Aidibe
10044
Icham Aidibe 2014.11.20 12:26  
belido:
yes it is.
So what's the profit variable ?
Stanislav Korotky
17932
Stanislav Korotky 2014.11.20 12:46  
blouf:
So what's the profit variable ?
This is the returned value with profit in your account currency.
Irwan Adnan
886
Irwan Adnan 2014.11.20 13:45  
blouf:
So what's the profit variable ?
the profit variable is a variable name you choose where the result will be put in it.
Icham Aidibe
10044
Icham Aidibe 2014.11.20 14:58  
belido:
the profit variable is a variable name you choose where the result will be put in it.

Ok thank !

May you know a function that tell max lot size buyable/sellable for the account ?

Irwan Adnan
886
Irwan Adnan 2014.11.20 17:02  
blouf:

Ok thank !

May you know a function that tell max lot size buyable/sellable for the account ?

that is also i am looking for advice in MQL5. In MQL4 potential lot size can be calculated by AccountFreeMargin()/MarketInfo(Symbol(),MODE_MARGINREQUIRED). And maximum lot for a broker can be calculated  from MarketInfo(Symbol(),MODE_MAXLOT)
Alain Verleyen
Moderator
30752
Alain Verleyen 2014.11.20 17:16  
   MqlTick tick;
   double margin;
   if(!SymbolInfoTick(Symbol(),tick) || !OrderCalcMargin(ORDER_TYPE_BUY,Symbol(),1.0,tick.ask,margin)) return;
   double maxLots=AccountInfoDouble(ACCOUNT_FREEMARGIN)/margin;
   printf("Margin =%f FreeMargin=%f Max lots to buy=%f",margin,AccountInfoDouble(ACCOUNT_FREEMARGIN),maxLots);
Irwan Adnan
886
Irwan Adnan 2014.11.20 17:51  
angevoyageur:

Thanks friend.

 

It works

and answering blouf, max lot (broker restriction) 

SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX)
Icham Aidibe
10044
Icham Aidibe 2014.11.20 18:37  
angevoyageur:

Thanks !

@belido : yep, just return the max buyable lots for the symbol, not for the current account

To add comments, please log in or register