Also, my EA will run M15,M30,H1 and H4. Could it due to too many time frames x 24 pairs that MT4 simply could not cope with the load?
Are you checking function return values and reporting all errors to the log ? do you use a mutex to prevent EAs trying to get the trade context at the same time ? how are you checking that your EA is doing what it should be doing ?
Hi RaptorUK,
Thanks for your help.
I did include all error checks for functions like OrderSend, ordermodify, etc. I have been running this EA structure for many months, and all possible errors have been handled. Except 'TradeContextBusy" which is out of my control. My EA will simply ignore such message and retry a few times. If fail after a few attempts, the signal/order is aborted.
How do I know that EA is not being fired by some of the pairs? When I tried to find out why some of the stop losses are not being moved, I inserted alert messages at a few places in my EA, just to display if the EA in each chart is being fired, and only 70% of them (24 pairs) triggered the alert messages. In my example, AUDUSD order was triggered before, and it means that the EA was fired from AUDUSD. However, subsequently the EA was not fired from there while the same EA is being fired from other charts. Therefore its stop loss was not moved.
I am not aware of "mutex", could you please elaborate further?
I am using i7 CPU notebook, and the usage is 20%,30%,70%,6% for 4 processors.
Please help. Thanks .....
Novalight
Hi RaptorUK,
Thanks for your help.
I did include all error checks for functions like OrderSend, ordermodify, etc. I have been running this EA structure for many months, and all possible errors have been handled. Except 'TradeContextBusy" which is out of my control. My EA will simply ignore such message and retry a few times. If fail after a few attempts, the signal/order is aborted.
How do I know that EA is not being fired by some of the pairs? When I tried to find out why some of the stop losses are not being moved, I inserted alert messages at a few places in my EA, just to display if the EA in each chart is being fired, and only 70% of them (24 pairs) triggered the alert messages. In my example, AUDUSD order was triggered before, and it means that the EA was fired from AUDUSD. However, subsequently the EA was not fired from there while the same EA is being fired from other charts. Therefore its stop loss was not moved.
I am not aware of "mutex", could you please elaborate further?
I am using i7 CPU notebook, and the usage is 20%,30%,70%,6% for 4 processors.
Please help. Thanks .....
Novalight
Hi RaptorUK,
I read another thread about "Trade Dispatcher", and you also mentioned there about mutex as a solution to avoid contention of checking isTradeContextBusy. Does it mean that I can use a GlobalVariable as a token to make sure that at anyone time, there is only one pair can issue send, modify, close, etc.? If that is what you mean by mutex, then I can implement that easily. The question is, does that explain why EA was not fired from some of the pairs? If my EA was not fired from some of the pairs, these pairs will not have the opportunity to check the token before issuing server related orders.
Please help. Thanks....
Novalight
How is your EA doing the trailing on OrderStopLoss()
Don't trail on every Point
Make use of an TrailingStep of a few pips to avoid much tradecontextbusy errors
Thanks DeVries & WHRoeder.
The trailing is not a problem as the trailing pips are 20 to 30 pips. I am not even sure if TradeContextBusy is the problem here. Even if there are no new orders triggered, and no stop losses need to be moved, my EA only get fired by a few pairs, while the rest are not firing my EA. Here is what I did to explore the situation further. I place an Alert message in the main routine of the start section, and that alert message simply display the symbol when the EA is fired. This is just to find out which pair is running the EA properly. I am not talking about those routines that send order, modify or close orders. Just by checking which pairs fire the EA (through the running of start section), I can only see few pairs' symbols being displayed repeatedly, and the rest of the pairs as though are non existence. During that test process, there are no stop losses need to be moved, or new orders being triggered.
If I may put it simply, some pairs are firing my EA repeatedly, while the rest seem to be idling and not running the EA at all.
I hope that I don't have to revamp my EA completely just to force the running of EA through each pair by round robin method on a single chart.
Coming back to TradecontextBusy issue. If server contention is the issue, I believe that I can define a token through Globalvariables to control the execution of send, modify and close, one at a time. I think that can be implemented easily. Please correct me if I am wrong.
Thanks .....
Novalight
Hi Ubzen,
It is not that some pairs firing EA and some pairs don't. The actual situation is, some pairs fire EA, and the same pairs suddenly did not fire EA later. As I have given an example before, AUDUSD fired the EA and an order was issued. After running for sometime, AUDUSD did not fire the EA for whatever reason, and therefore its stop loss is not moved. That might have mislead readers thinking that it was a TradeContextBusy issue, but the actual fact is, AUDUSD did not fire the EA, and therefore, it could not run any of the routines such as trailing the stop loss, send order, or close order. When I inserted the alert messages in the main program to see which pairs firing the EA, and AUDUSD did not show up. But it has fired the EA before. All in all, all pairs will fire the EA at some point in time, but some pairs will simply become idling. So there are no specific group of pairs that fire the EA, or a specific group of pairs that don't. I hope that I have clarified the problem situation.
Thanks.
Novalight
novalight: "If I may put it simply, some pairs are firing my EA repeatedly, while the rest seem to be idling and not running the EA at all."
Take the symbol which is Not-Firing within your Alert test. Close all other charts and place this EA upon that symbol. Does it still not Fire or Idling? Make sure to use the Actual Log.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void start(){ Print("Symbol="+Symbol(),"____Bid="+Bid,"____Ask="+Ask); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have EA applied on each chart, and I have 24 pairs of charts running at anyone time. EA on each chart has successfully triggered orders accordingly. However, I notice that not all charts fire my EA. Somehow a few charts simply do not fire the EA at certain time, and I have no idea why it happened. For example, I have AUDUSD triggered an order, and my EA subsequently moved the stop loss to break even. everything worked accordingly. After sometime, AUDUSD did not fire my EA, and therefore the stop loss was not moved accordingly. I placed an Alert on my EA to show the symbol of the chart firing the EA, most of them shown up, but a few of the currency pairs simply did not fire the EA. AUDUSD is one of them.
Anyone has similar experience before? Please advise if you do come across the same situation.
Also, my EA will run M15,M30,H1 and H4. Could it due to too many time frames x 24 pairs that MT4 simply could not cope with the load?
Any advise or help will be greatly appreciated.
Many thanks.
Novalight