How to get the maximum number of open positions

 

How to get the maximum number of open positions of broker's limit, not the number of Lots. I don't know using which function.

Thanks in advance

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
sdlg:

How to get the maximum number of open positions of broker's limit, not the number of Lots. I don't know using which function.

Thanks in advance

I think you can only get the maximum number of open pending orders. I don't think there is a limit on the number of positions.

https://www.mql5.com/en/docs/constants/environment_state/accountinformation

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
, then each symbol positions will be closed in the same order, in which they are opened, starting with the oldest one. In case of an attempt to close positions in a different order, the trader will receive an appropriate error. There are several types of accounts that can be opened on a trade server. The type of account on which an MQL5 program...
 
nicholish en:

I think you can only get the maximum number of open pending orders. I don't think there is a limit on the number of positions.

https://www.mql5.com/en/docs/constants/environment_state/accountinformation

Thank you, i see.

 
Margin requirements will be the limiting factor, not the count.
 
William Roeder:
Margin requirements will be the limiting factor, not the count.

Is that really true?

At least one broker (Roboforex) has a limitation in number of open positions, not only in number of pending orders.

On the Roboforex site you can read:

Maximum number of open positions for MT5 accounts 1000
Maximum number of active orders for MT5 accounts 500


My question is: is there any MQL5 function to get the maximum number of open positions?

Thanka for your answer.

Matthias

 
Dr Matthias Hammelsbeck: My question is: is there any MQL5 function to get the maximum number of open positions?

Why have you posted your MT5 question in the MQL4 section, (bottom of the Root page)?

 
William Roeder:

Why have you posted your MT5 question in the MQL4 section, (bottom of the Root page)?

Because I did not notice it!
I'm so sorry.😎
 
sdlg:

How to get the maximum number of open positions of broker's limit, not the number of Lots. I don't know using which function.

Thanks in advance

very simple

@ sdlg

//+------------------------------------------------------------------+
//|                                                        accou.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

double TotalOrderSize(string GlnSymbol)
  {
   double SymbolUsedOrder=0;
   int total = OrdersTotal();
   for(int ih=total-1; ih>=0; ih--)
     {
      bool ddy=OrderSelect(ih, SELECT_BY_POS);
      if(OrderSymbol()==GlnSymbol) SymbolUsedOrder=SymbolUsedOrder+OrderLots();
      }
      
      return SymbolUsedOrder;
      }
void OnStart()
  {
//---
   double MaxLot=MarketInfo(Symbol(),MODE_MAXLOT); 
   double total=TotalOrderSize(Symbol());
   double UsableOrder=MaxLot-total;
   Alert("Max Lot Size="+string(MaxLot)+" Used Lots="+string(total)+" Usable Lots="+DoubleToStr(UsableOrder,2));
     }
//+------------------------------------------------------------------+
 

AccountInfoInteger(ACCOUNT_LIMIT_ORDERS)

ACCOUNT_LIMIT_ORDERS

Maximum allowed number of open positions and active pending orders (in total), 0 — unlimited

int

Reason: