MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
MQL5.com Wall - 24-Hour News Channel About the Life of the Community

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

 
Secrets of MetaTrader 4 Client Terminal
21 way to ease the life: Latent features in MetaTrader 4 Client Terminal. Full screen; hot keys; Fast Navigation bar; minimizing windows; favorites; traffic reduction; disabling of news; symbol sets; Market Watch; templates for testing and independent charts; profiles; crosshair; electronic ruler; barwise chart paging; account history in the chart; types of pending orders; modifying of StopLoss and TakeProfit; undo deletion; chart print.
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
1184
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
1184
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