CTrade PartialClose() not working ? Error 4756 - Code 10004 HELP

 

Hello people:

if(!trade.PositionClosePartial(ticket_hedge_short[m],lots_toclose,10))
   Print("Error Partial Close: ", _LastError," - Code: " ,trade.ResultRetcode(), " - Description: ",trade.ResultRetcodeDescription() ," - BID | ASK ", info.Bid() , " | " , info.Ask());
if(!trade.PositionClosePartial(ticket_recovery[i],lots_toclose,10))
   Print("Error Partial Close: ", _LastError," - Code: " ,trade.ResultRetcode(), " - Description: ",trade.ResultRetcodeDescription() ," - BID | ASK ", info.Bid() , " | " , info.Ask());

I would like to close partially these 2 orders.

Only the first line will close, the second one dosn't close.

If i swap these two lines it will again close the first one but not the second one.


I am using MetaQuotes Demo server for test the strategy .


If I insert between the two lines :

Sleep(50);

It works.. sometimes.. maybe because my server latency is less : 33ms (?)


I want to find a definite solution to this..

I thought placing SetAsyncMode(TRUE) would fix the problem but it doesnt.. 


ANY ADVICE?


This is the log in the strategy tester:

2022.10.10 22:16:10.211 2022.09.05 08:11:21   CTrade::OrderSend: instant sell 0.03 position #6 EURCHF.Renko.ATR8.0 at 0.97224 [requote (0.97225/0.97227)]

2022.10.10 22:16:10.211 2022.09.05 08:11:21   Error Partial Close: 4756 - Deviation : 10 - Code: 10004 - Description: requote (0.97225/0.97227) - BID | ASK 0.97224 | 0.97226



 
arimbur:

Do not double post!

I have deleted your duplicated topic.

 
arimbur:

Hello people:

I would like to close partially these 2 orders.

Only the first line will close, the second one dosn't close.

If i swap these two lines it will again close the first one but not the second one.


I am using MetaQuotes Demo server for test the strategy .


If I insert between the two lines :

It works.. sometimes.. maybe because my server latency is less : 33ms (?)


I want to find a definite solution to this..

I thought placing SetAsyncMode(TRUE) would fix the problem but it doesnt.. 


ANY ADVICE?


This is the log in the strategy tester:

2022.10.10 22:16:10.211 2022.09.05 08:11:21   CTrade::OrderSend: instant sell 0.03 position #6 EURCHF.Renko.ATR8.0 at 0.97224 [requote (0.97225/0.97227)]

2022.10.10 22:16:10.211 2022.09.05 08:11:21   Error Partial Close: 4756 - Deviation : 10 - Code: 10004 - Description: requote (0.97225/0.97227) - BID | ASK 0.97224 | 0.97226



Solved : 


1) Do not use MetaQuotes-Demo Server for Strategy tester

2) Do not use Instant Execution brokers (They are market makers)

Reason: