My Expert Advisors cannot modify order in Live account

 
My Expert Advisors cannot modify order in Live account

--------------------------------------------------------------------------------

the massages in 'Expert' page of 'Terminal' window are as follows:
2005.09.21 14:04:57 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6
2005.09.21 13:59:57 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6
2005.09.21 13:49:55 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6
2005.09.21 13:46:06 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6

while the same Expert running on Demo Account is successful to modify order, with massages:
2005.09.21 13:05:15 [xxxx] EURUSD,M5: modify #1073297 buy 0.10 EURUSD at 1.2196 sl: 1.2114 tp: 1.2358 ok

Error #6 means "No connection with trade server", but I need to modify order (change s/l and t/p), how should I do to solve this problem?
 
My Expert Advisors cannot modify order in Live account

--------------------------------------------------------------------------------

the massages in 'Expert' page of 'Terminal' window are as follows:
2005.09.21 14:04:57 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6
2005.09.21 13:59:57 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6
2005.09.21 13:49:55 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6
2005.09.21 13:46:06 [xxxx] EURUSD,M5: modify buy. #0 1614423 failed with error #6

while the same Expert running on Demo Account is successful to modify order, with massages:
2005.09.21 13:05:15 [xxxx] EURUSD,M5: modify #1073297 buy 0.10 EURUSD at 1.2196 sl: 1.2114 tp: 1.2358 ok

Error #6 means "No connection with trade server", but I need to modify order (change s/l and t/p), how should I do to solve this problem?


I might misunderstand you, but

1. did you test if you have a connection with the server of the live account?
2. did you try to do one trade with the live account manually?

No the next two should cause another error message, but double check them please as well.

3. did you apply the expert to the regarding chart with the option "Allow Live Trading"?
4. did you enable under tools->options->Expert-Advisors "Allow live trading" and "Allow Experts" (this last might be redundant, but try it)
 
Reading you post again, I see that you speak of "modifing". My Bad. Anyway 1. + 2. apply still.

What I do in general, before all kind of OrderSend, OrderModify and OrderClose is to do a IsTradeAllowed(). For this I made a little function with a timeout, which looks like that:


bool func_Can_I_trade(int timeout) {
datetime OldCurTime=0;

OldCurTime=CurTime();
while (!IsTradeAllowed()) {
if(OldCurTime+timeout<=CurTime()) {
Print("func_Can_I_trade: Not yet");
return(true);
}
}
Print("func_Can_I_trade: Couldn't trade within " + timeout + " secs.");
return(false);
}


This should at least make it evident to your system, that somethings wrong, before it posts any Order*
 
I will test more about my codes, adding in IsTradeAllowed(). But there's interesting points now:

1. when close the metaTrader(Live), and launch it again, modify function works immediately.
2. this problem never appear in a demo account, I have device a demo account with exact the same EA and works well.

the source code is
orderResult=OrderModify(ticket,0,stoploss_should,takeprofit_should,0,COLOR_BUY_MODIFY);
if(!orderResult) Print("modify buy. #",i," ",ticket," failed with error #",GetLastError());
 
George,

is it possible that you're shooting these too quickly. I think I read somewhere that there's a limit to how quicky you may send new orders or maybe even mods.



Markus
 
I add "Print("Before modify buy/sell #",ticket,", IsTradeAllowed()=",lTradeAllow);" before the modify command, and the reponses are:

2005.09.23 08:49:36 [xxxx] EURUSD,M5: Before modify sell #1621045, IsTradeAllowed()=1
2005.09.23 08:49:36 [xxxx] EURUSD,M5: modify sell #0 1621045 failed with error #6

My EA send out modify command every 5 minutes 7:39-9:04 this morning:
1. the first one succeed, the rest all with error #6 (No connection with trade server).
2. At 7:41, there was a message in "Journal", says "2005.09.23 07:41:43 TradeContext: ping failed"
3. 1 command every 5 minutes, it is not too quickly, is it?
4. when I close the metaTrader and restart it, the following modify works! but same problems occur after long time (maybe 12 hours).
5. my internet connection is not perfect, there are random short-time breakdowns, one breakdown maybe lasting around 1-3 seconds.
6. still no such problem at the exact same EA on Demo account.

Is it possible that there is a bug in the Live server which cause connection loss after modify in a long running EA?

Can we regain the connection to the server by our own codes in EA? If can, problem solved.
 
Have you seen the post about the new build 182 pre (somewhere here among the first 10 or 20)? Slawa said, that they fixed some problems with lost connections etc.



Markus
 
I'll try the new version out. Thank you!
 
I have just tried the new pre183 version. Same problem -- the first Modify works, but the second and later on Modify every 5 minutes after failed as before. So, the new pre183 version didn't solve my problem.
 
However, I can't be bother in this minor problem. I concede and revise my EA. Now, if future versions solve this problem, fine, I get the expected operation, but if problem not solved, the failed Modify Command won't do much harm to me.

Thanks to fukinagashi and Shimodax! For your reply!
Reason: