MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Check MetaTrader Market in order to find your Expert Advisor

How To Limit the Total of Transactions per Day

Back to topics list To post a new topic, please log in or register
avatar
2
aristonchai 2009.05.06 17:57
 

Hi, can anyone show me the code how to limit the total of transactions per day? I see most of the EA only limits open position per execution.

Let say I need to limit the transaction only 2 transaction per day, because if more than two, the risk of trade will increase.


thanks for helping.


ariston

 
Non-standard Automated Trading

Non-standard Automated Trading

Successful and comfortable trading using MT4 platform without detailed market analysis - is it possible? Can such trading be implemented in practice? I suppose, yes. Especially in terms of the automated trading!

avatar
443
blogzr3 2009.05.06 18:42 #
 
Do a search for "only 2 trade per day"...
avatar
1397
cloudbreaker 2009.05.06 19:04 #
 
aristonchai:

Hi, can anyone show me the code how to limit the total of transactions per day? I see most of the EA only limits open position per execution.

Let say I need to limit the transaction only 2 transaction per day, because if more than two, the risk of trade will increase.


thanks for helping.


ariston

Easy.

Just perform a loop to count the number of open orders each time before you place a trade.

Only place a trade when the result is less than 2.

 
avatar
1131
jjc 2009.05.06 19:11 #
 
cloudbreaker:

Just perform a loop to count the number of open orders each time before you place a trade.

Only place a trade when the result is less than 2.

Fleshing this out in pedantic detail, for aristonchai's benefit: you'll probably need to do two loops. One to check closed orders, and one to check open/pending orders, and then add the totals together.

 
avatar
1131
jjc 2009.05.06 19:27 #
 
jjc:

Fleshing this out in pedantic detail, for aristonchai's benefit: you'll probably need to do two loops. One to check closed orders, and one to check open/pending orders, and then add the totals together.

In even more pedantic detail, there's a potential problem with anything which relies on looping through the account history: the user can break it. Any date filtering which is applied on screen to the list of trades in the account history also affects what an EA sees, in terms of things such as OrdersHistoryTotal(). Therefore, if the user applies a date filter such as "Last Month", then the EA will not be able to see any orders placed and closed today. Also worth bearing in mind that attempts to select a historic closed order using OrderSelect(x, SELECT_BY_TICKET) also fail if the order has been filtered out of the account history. (This, incidentally, is a horrible design decision by Metaquotes, and something which I really hope gets changed in MT5.)

 
Back to topics list  

To add comments, please log in or register