ERR_TRADE_SEND_FAILED
4756
Trade request sending failed
for( int i = totalOrders - 1; i >= 0; i-- )
I only scanned your code quickly. I did not analyse it in depth. There may be other issues.
ERR_TRADE_SEND_FAILED
4756
Trade request sending failed
I only scanned your code quickly. I did not analyse it in depth. There may be other issues.
Hello Fernando,
I modified my script a bit so I can see if the script finds the correct orders and I implemented your modification. The script finds all pending orders but it doesn't delete any of them. Always error 4756 and I don't understand this error. Additionally I receive this error in the journal: "failed cancel order #0 buy 0 at market (invalid request)".
void OnStart() { int totalOrders=OrdersTotal(); for (int i=totalOrders-1;i>=0;i--) { ulong ticket=OrderGetTicket(i); if (OrderSelect(ticket)) { string orderSymbol=OrderGetString(ORDER_SYMBOL); Print(orderSymbol+" "+(string)ticket); MqlTradeRequest request; MqlTradeResult result; ZeroMemory(request); ZeroMemory(result); request.action=TRADE_ACTION_REMOVE; request.position=ticket; if (!OrderSend(request,result)) { PrintFormat("OrderSend error %d",GetLastError()); // if unable to send the request, output the error code } PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order); } } }
- You are not checking the return code for OrderGetTicket() to see if it is valid.
- No need to select the order. It is already selected by OrderGetTicket() .
- Just initialise the structure as empty instead of using ZeroMemory()
- Set the Order ticket and not the Position ticket.
ulong ticket = OrderGetTicket( i ); if( ticket > 0) { MqlTradeRequest request = {}; MqlTradeResult result = {}; request.action = TRADE_ACTION_REMOVE; request.order = ticket;
- You are not checking the return code for OrderGetTicket() to see if it is valid.
- No need to select the order. It is already selected by OrderGetTicket() .
- Just initialise the structure as empty instead of using ZeroMemory()
- Set the Order ticket and not the Position ticket.
Thank you so much, Fernando! Now it works perfect. The problem was that I copied this code from my SL to breakeven script and there I need to use position instead of order.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey guys,
I always get error #4756 and I have no idea why... can anyone help?