MQL5.com Wall - 24-Hour News Channel About the Life of the Community
MQL4.com is moving to MQL5.com. Sign up for the new web portal for traders!

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

 
Next Targets In USD/JPY, EUR/USD - SocGen
Japanese flow data show a steady acceleration in buying of foreign bonds and equities by Japanese investors, which has not overtaken foreign buying of Japanese assets, notes SocGen. "This is a source of comfort for yen bears, but the overnight move in USD/JPY has broken the recent range and exposed a clear risk of a flush out of yen shorts. USD/JPY 117 is a potential target," SocGen projects. For the EUR, SocGen notes the recent improvement in Eurozone data. "A straw in the wind, a swallow signalling economic summer or just a sign that things aren’t getting any worse?
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
1201
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
1201
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