Count number of oders

 

Hello, 

Currently i am trying to limit number of order to 4,  opened by EA using OrderTotal() but still EA opens more then 4 orders 

here is snippet 

if( OrderTotal() <=4)

{

//here goes code 

Please help 

Documentation on MQL5: Trade Functions / OrdersTotal
Documentation on MQL5: Trade Functions / OrdersTotal
  • www.mql5.com
Do not confuse current pending orders with positions, which are also displayed on the "Trade" tab of the "Toolbox" of the client terminal. An order is a request to conduct a transaction, while a position is a result of one or more deals.
 
MQL4 or MQL5 ?
 
Keith Watford:
MQL4 or MQL5 ?
MT4 
 
shaikh_shafique:
MT4 

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

Please edit your post and

use the code button (Alt+S) when pasting code

if( OrderTotal() <=4)

{

//here goes code 

} 
What is OrderTotal() ??
 
Keith Watford:

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

Please edit your post and

use the code button (Alt+S) when pasting code

What is OrderTotal() ??
It is function to get totalorders in mt4
 
shaikh_shafique:
It is function to get totalorders in mt4

Do you mean OrdersTotal() ??

 
Keith Watford:

Do you mean OrdersTotal() ??


YEP

 
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2017.07.19

  2. shaikh_shafique: YEP
    Don't post code that won't even compile. If you want help with your code, post your code.
 
shaikh_shafique:

Do not double post!

I have deleted your duplicate topic.

 
if( OrdersTotal() <=4)

{

//If there are 5 or more orders currently open this block of code will not be executed
//So if new orders are opened and there are already 5 orders currently open, the new orders are not being opened in this block of code. 

} 

If you want to limit it to no more than 4 currently open orders you should use

if( OrdersTotal() <4)
 
Thanks will try this :-) 
Reason: