How do I check my order has gone through and if not, do the order again?

Dean-Trades  
I have IOC market orders set up with a sl and tp in place. The sl and tp are based on a point amount not a set price. So it just ads a sl of 100 points for example from wherever the order entry is.

Sometimes my orders don't go through. They get rejected with no information as to why.
The only thing I have noticed is that from when the order was entered to when the order got rejected its always a time of 2 minutes and 10 seconds. Not sure why that is? It's like some sort of order rejection/cancellation if it takes longer than 2 minutes 10 seconds?

I was thinking one way to perhaps get around this issues is for my python script to perform a check to see if the order went through successfully and if not, do the order again.

How would I achieve this if it's possible?

Thanks
William Roeder  
Dean-Trades: They get rejected with no information as to why.

Wrong. Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
          What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
          Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)

Dean-Trades  
William Roeder #:

Wrong. Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
          What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
          Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)

Hi,

The only code I have is the retcode  10006 which just specifies the order was rejected. It doesn't go on to explain why it was rejected.

In my MT5 journal, there is nothing there but the word rejected. No code or anything else indicating a reason why.

Am I missing something here?

Thanks

William Roeder  
Dean-Trades #: retcode  10006 which just specifies the order was rejected. It doesn't go on to explain why it was rejected.

It doesn't go on,, you have to go on and look into the results.

Dean-Trades  
William Roeder #:

It doesn't go on,, you have to go on and look into the results.

Where in MT5 can I go to look at the results William?

If it's a folder with MT5, what's the folder called where I am able to get this information and then relay that back to you for further analysis?

William Roeder  
Dean-Trades #: Where in MT5 can I go to look at the results William?
bool  OrderSend(
   MqlTradeRequest&  request,      // query structure
   MqlTradeResult&   result        // structure of the answer
   );

5

Fernando Carreiro  

In a follow-up to the previous post by William, since you mentioned using Python and not MQL, have a look at the documentation example for order_send.

Here is the section I am referring to ...

# check the execution result
print("1. order_send(): by {} {} lots at {} with deviation={} points".format(symbol,lot,price,deviation));
if result.retcode != mt5.TRADE_RETCODE_DONE:
    print("2. order_send failed, retcode={}".format(result.retcode))
    # request the result as a dictionary and display it element by element
    result_dict=result._asdict()
    for field in result_dict.keys():
        print("   {}={}".format(field,result_dict[field]))
        # if this is a trading request structure, display it element by element as well
        if field=="request":
            traderequest_dict=result_dict[field]._asdict()
            for tradereq_filed in traderequest_dict:
                print("       traderequest: {}={}".format(tradereq_filed,traderequest_dict[tradereq_filed]))

Please note, that I do not code in Python so I will not be able to offer more explanation than this.