Invalid request - just started and can't figure it out... - page 8

 
papaklass:

I have it implemented in the same way, only through functions.


I see. Your code is similar to MK's - between OrderCheck and OrderSend there is a layer of error handling by the user.

 
papaklass:

I have it implemented this way, only through functions.

OrderCheck is implicit and necessarily checked inside OrderSend.

So if the order is not filled correctly, the response will be returned immediately without sending it back to the server.

 
papaklass:

See what the handbook says about this:

First selection: we see that the function is for trade transactions and no mention of checks.

Well, if I say there are checks, then it's true.

No order leaves the terminal without hard checks.

Second highlighting: we see that checks are performed on the server and the developers recommend using OrderCheck() to check the request before sending it to the server. Again, there is no mention that OrderSend() performs any validation.

We specifically recommend that traders have the opportunity to find out in advance if the order is filled correctly, and take the appropriate actions.

Whoever wants to - can pre-check it. Who does not want to, we will check and return similar answers for them anyway.

The only place where it's mentioned that checking before sending request is "In case of successful basic checking of structures (pointer check) ....". But checking of pointers and checking of values of request structure fields for errors is not the same thing. And the developers' recommendation to use the OrderCheck() function is indirect proof that OrderSend() does not perform real error checking before sending a request to the server. Otherwise why should we make "buttered": OrderSend() checks first, and then the same check must be performed by OrderCheck() again?

So from the reference it follows unambiguously that the check is performed solely on the server!

No one will miss an erroneous or excessive flow of requests to the server.

Basic logic is enough to understand this. And we'll expand the documentation.

 
sergeev:

You don't have it. All errors are handled by business logic.

I have one. Business logic handles events related to business logic (e.g., order placing failure), but all the rest (e.g., server response delay) - a universal template, based on which absolutely any expert can be implemented.

But MT5 is many times more complicated in terms of handling return codes + asynchrony.

That's what we are talking about, as I have similarly written before, and there is zero information on this subject. And for years MKs are trying in every way to dissociate themselves from its provision. This is what I wrote - dealers benefit from a product where there are points that lead to leakage, i.e. for MQ it is a factor in increasing sales. Alas, we are in a market where competitors(us and MQ), not comrades.

You are asking the impossible from a wrapper. The standard library is not business logic. It's a wrapper "over" the terminal functions. A wrapper over the stuffing of the candy.

Then there is little point in such a structuring.

But the wrapper cannot guarantee anything, as it is you who act as a guarantor. Your business logic. :)

Just like the Print function cannot guarantee free space on disk. And logging errors. You have to use other functions for error handling and they are case specific.

Not even the right wrapper can guarantee everything, but it can many things relating to related functions.

-Alexey-, let's have a chat about specific flaws and you voice specific flaws that you would like to fix.

It's already been written about specific more than once. If MQ is unable to provide a ready-made solution, let them at least make a manual on error handling and return codes. Unlocked in every way possible. In documentation for 4 this was partly present (e.g. wait for 30 seconds in such a case), partly users defined from experience handling undocumented situations. For 5 there is nothing at all. And since there is, no one will use it.

Well if that's how MQ responds because the simply created trading infrastructure does not allow it in principle, then what can I say - it's a complete failure of the whole MT5 project, given that there are an incredible mass of other shoals as well.

If you want, you can go through each return code and look at the main possible situations.

I would gladly do it with such an experienced MQL5 Expert Advisor like you. We will wait for the time and necessity. Thank God I still have 4 which is much more comfortable in many aspects.

 

-Alexey-:

a ready-made solution, at least a guide to error handling and return codes


which code causes processing issues?


Code

Identifier

Description

10004

TRADE_RETCODE_REQUOTE

Requote

10006

TRADE_RETCODE_REJECT

Request rejected

10007

TRADE_RETCODE_CANCEL

Request cancelled by trader

10008

TRADE_RETCODE_PLACED

Order placed

10009

TRADE_RETCODE_DONE

Order executed

10010

TRADE_RETCODE_DONE_PARTIAL

Requisition partially executed

10011

TRADE_RETCODE_ERROR

Request processing error

10012

TRADE_RETCODE_TIMEOUT

Request cancelled due to expiration of time

10013

TRADE_RETCODE_INVALID

Incorrect request

10014

TRADE_RETCODE_INVALID_VOLUME

Incorrect volume in request

10015

TRADE_RETCODE_INVALID_PRICE

Incorrect price in request

10016

TRADE_RETCODE_INVALID_STOPS

Incorrect stops in request

10017

TRADE_RETCODE_TRADE_DISABLED

Trade prohibited

10018

TRADE_RETCODE_MARKET_CLOSED

Market is closed

10019

TRADE_RETCODE_NO_MONEY

Insufficient funds for execution of request

10020

TRADE_RETCODE_PRICE_CHANGED

Prices changed

10021

TRADE_RETCODE_PRICE_OFF

No quote to process request

10022

TRADE_RETCODE_INVALID_EXPIRATION

Invalid expiry date in the request

10023

TRADE_RETCODE_ORDER_CHANGED

Order status changed

10024

TRADE_RETCODE_TOO_MANY_REQUESTS

Too frequent requests

10025

TRADE_RETCODE_NO_CHANGES

No change in request

10026

TRADE_RETCODE_SERVER_DISABLES_AT

Auto-trading denied by server

10027

TRADE_RETCODE_CLIENT_DISABLES_AT

Autotrading prohibited by client terminal

10028

TRADE_RETCODE_LOCKED

Request blocked for processing

10029

TRADE_RETCODE_FROZEN

Order or position frozen

10030

TRADE_RETCODE_INVALID_FILL

Unsupported balance order type is indicated

10031

TRADE_RETCODE_CONNECTION

No connection to the trade server

10032

TRADE_RETCODE_ONLY_REAL

Operation is allowed for real accounts only

10033

TRADE_RETCODE_LIMIT_ORDERS

Limit on the number of pending orders reached

10034

TRADE_RETCODE_LIMIT_VOLUME REACHED

Reached limit on volume of orders and positions for this symbol


Updated: 2012.11.14
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
 

For example 10004. Where is it written what to do? And there was at least something in the quadruple documentation:

Можно без задержки обновить данные при помощи функции RefreshRates и повторить попытку. Если ошибка не исчезает, необходимо прекратить все попытки торговых операций и изменить логику программы.

 
sergeev:

which code raises processing issues?

10006 (what reason is rejected, what other reasons could there be that are not listed in the other codes?)

10011, 10013, 10028

 
A100:

10006 (what reason is rejected, what other reasons could there be that are not stated in the other codes?)

10011, 10013, 10028

I support the question. MQ, a strong request to you. Please comment on these 4 codes in as much detail as possible.
 

Colleagues, already sick of searching for the truth. The topic is similar to what I need, so I am writing here, please help!

I place the order with immediate execution, while it is hanging I check the price every tick and if it is possible I trail it. But for some reason I always get error 10013. I have looked through all possible forums and added almost all of the lines of the initial order (although the description says that only the symbol, action and sl and tp are sufficient for this type of action. Nothing works! Here's the code.

// проверяем условие на открытую сделку
if (f_IsDealOpened()>0)
{  
   // здесь надо написать условия для коррекции ордеров
 MqlTradeRequest chrequest={0};
    if (1)//(is_Str2)
   {
    PositionSelect(NULL);
    if(PositionGetInteger(POSITION_TYPE)==0)
    {
        chrequest.symbol=PositionGetSymbol(0);
        chrequest.order=PositionGetInteger(POSITION_IDENTIFIER);
        chrequest.volume=PositionGetDouble(POSITION_VOLUME);
        chrequest.action=TRADE_ACTION_SLTP;
        chrequest.sl = latest_price.bid - TrailingStop;
        chrequest.tp = PositionGetDouble(POSITION_TP);

     }
     else
     {
        chrequest.symbol=PositionGetSymbol(0);
        chrequest.order=PositionGetInteger(POSITION_IDENTIFIER);
        chrequest.volume=PositionGetDouble(POSITION_VOLUME);
        chrequest.action=TRADE_ACTION_SLTP;
        chrequest.sl = latest_price.ask + TrailingStop;
        chrequest.tp = PositionGetDouble(POSITION_TP);
        Alert(PositionSelect(NULL));
     
     }    
    }
     MqlTradeResult chresult;
     if (OrderSend(chrequest,chresult)==0) 
         {
             Alert("Ошибка расчета функции OrderSend!");
             return;
         }    
         // анализируем код возврата торгового сервера
         if(mresult.retcode==10009 || mresult.retcode==10008) //запрос выполнен или ордер успешно помещен
           {
            Alert("Ордер по изменению SL успешно помещен, тикет ордера #: ",mresult.order,"!!");
            open_order_ticket = mresult.order;
            open_order_price = mresult.price;
            return;
           }
         else
           {
            Alert("Запрос на измнение ордера не выполнен - код ошибки: ",GetLastError());
            return;
           }
   
   
   return;
}