Maximum allowed Orders

To add comments, please log in or register
Raphael Schwietering
9020
Raphael Schwietering  

Hello,


have someone an idea or codes snippet for me that an ea only open so much trades that i have define in an input value.


Now i use this

if(OrdersTotal() >= maxOrders) 
{
Print("Maximum Orders");
        return;
}

but it looks like it is not working very well. 

Raphael Schwietering
9020
Raphael Schwietering  
No idea it looks like this Code count All open trades instead of only from ea
GrumpyDuckMan
882
GrumpyDuckMan  
Raphael Schwietering:

Hello,


have someone an idea or codes snippet for me that an ea only open so much trades that i have define in an input value.


Now i use this

but it looks like it is not working very well. 

Find the error with GetLastError()

if(OrdersTotal() >= maxOrders) 
{
Print("Maximum Orders");
        return;
}

BTW, it might need to be <= maxOrders

William Roeder
20207
William Roeder  
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
          Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
          MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
Pedro Pacheco
303
Pedro Pacheco  
I think the EA only counts the orders from the input magic. For example if you run the same EA on another pair or even in the same pair I think it will not count the orders. For that you might have to use a script I think.
To add comments, please log in or register