The code works in strategy tester, but when using in real trade, I get Error 4756 (Trade request sending failed) and retcode 10006 (Request rejected).
Anyone has any idea why this could not work? the SYMBOL_FILLING_MODE is 3 and the SYMBOL_EXPIRATION_MODE is 2. I can buy and sell normally if I use the "new order" thing from Metatrader. Please, any idea would be greatly appreciated. I ran out of ideas I could try to make it work.
this will generate in log the following lines:
11:36:36.695 Trades '1000015025': exchange buy 1.00 WDON15 at market
11:36:36.763 Trades '1000015025': rejected exchange buy 1.00 WDON15 at market
if I use the "new order" tool from Metatrader (that works), it generates these lines:
11:09:31.155 Trades '1000015025': exchange buy 1.00 WDON15 at market
11:09:31.207 Trades '1000015025': exchange buy 1.00 WDON15 at market placed for execution in 51 ms (Order received. Sending to OMS.)
11:09:32.459 Trades '1000015025': deal #4204115 buy 1.00 WDON15 at 3129.000 done (based on order #4913284)
Thanks
Not sure it helps, but some fields are not needed for a BUY with Market execution, try to remove them.
void OnTick() { MqlTradeRequest mrequest; MqlTradeResult mresult; ZeroMemory(mrequest); //---- mrequest.action = TRADE_ACTION_DEAL; mrequest.type_filling = ORDER_FILLING_FOK; mrequest.sl=0; mrequest.tp=0; mrequest.price = SymbolInfoDouble(_Symbol,SYMBOL_ASK); mrequest.symbol = _Symbol; mrequest.volume = 1; mrequest.magic = 0; mrequest.type = ORDER_TYPE_BUY; mrequest.deviation=10; mrequest.type_time=ORDER_TIME_DAY; //--- send order if(!OrderSend(mrequest,mresult)) { Alert(__FUNCTION__,": error ",GetLastError(),", retcode = ",mresult.retcode); } Sleep(30000); }
Not sure it helps, but some fields are not needed for a BUY with Market execution, try to remove them.
Hello Alain, thank you very much for you reply.
I tried your suggestion but unfortunately the error still persists. But since a veteran like you see no problem with that code, at least I am sure now that the issue is probably caused by the broker and not by the code. Thank you
If you have any other ideas I could try, please let me know.
I also tried changing the filling type and deleting the sl, tp and magic lines. Always the same error.
Hello Alain, thank you very much for you reply.
I tried your suggestion but unfortunately the error still persists. But since a veteran like you see no problem with that code, at least I am sure now that the issue is probably caused by the broker and not by the code. Thank you
If you have any other ideas I could try, please let me know.
I also tried changing the filling type and deleting the sl, tp and magic lines. Always the same error.
I can only suggest you to check ACCOUNT_TRADE_EXPERT.
Please report the solution here if you find it.
Not sure it helps, but some fields are not needed for a BUY with Market execution, try to remove them.
An other idea, can you try to set volume to 1.0 instead of 1.
And if that doesn't change, try with a double variable : double myvolume=1.0; mrequest.volume=myvolume
i am not sure if it matters in the mqltraderequest structure but you can also try to change the order.
In the initialization list, members can go in any order, but all members of the class will be initialized according to the order of their announcement.This should be taken into account in cases where the initialization of some members of the class depends on the values in other class members.
Market Execution
This is a trade order to open a position in the Market Execution mode. It requires to specify the following 5 fields:
action
symbol
volume
type
type_filling
i am not saying this should get rid of the error but i always tend to follow the same order as explained in the docs.
I can only suggest you to check ACCOUNT_TRADE_EXPERT.
Please report the solution here if you find it.
The ACCOUNT_TRADE_EXPERT returns 1.
Setting the volume that way did not show changes on the error, but that could be because the symbol will stop trading in less than 30 minutes counting from now, and when that happens the broker closes all trades from Metatrader (on my broker, metatrader is only to be used as a daytrade tool). So, to be sure I will have to try that again on monday.
I appreciate the time you are spending trying to help me.
If I find the solution I will make sure to make it known here.
The broker offers an expert advisor (a gui) to do trades(but they don't give the source code, only the ex), and it works, so there has to be a way.
If you have any other ideas, please share them with me, even if you think that they might not work. Thank you
i am not sure if it matters in the mqltraderequest structure but you can also try to change the order.
In the initialization list, members can go in any order, but all members of the class will be initialized according to the order of their announcement.This should be taken into account in cases where the initialization of some members of the class depends on the values in other class members.
Market Execution
This is a trade order to open a position in the Market Execution mode. It requires to specify the following 5 fields:
action
symbol
volume
type
type_filling
i am not saying this should get rid of the error but i always tend to follow the same order as explained in the docs.
I didn't think about that! Thank you!
It pains me that I will have to wait until monday to test it! I will let you know if it works or not.
If anyone else has other suggestions that have a chance to work, please let me know!
thanks
Guys! omg! I figured it out! You won't believe what actually solved the issue!
As I said before, my broker offered an EA (only the .Ex, not the source code). And when I made a trade with it, it worked. So, there was something that EA was doing that mine wasn't. Then I decided to use some mql5 functions to get all the info on the order it was generating and then I just copied all that info to my EA order and it worked. Then, when removing lines to try to figure out what was actually causing the order to be rejected before I found that it was the lack of the mrequest.comment line! (who could guess!)
So I just put the mrequest.comment line exactly like it was in the EA from the broker and the order actually went through!
Ty for the support guys!
Guys! omg! I figured it out! You won't believe what actually solved the issue!
As I said before, my broker offered an EA (only the .Ex, not the source code). And when I made a trade with it, it worked. So, there was something that EA was doing that mine wasn't. Then I decided to use some mql5 functions to get all info on the order it was generating and then I just copied all that info to my EA order and it worked. Then, when removing lines to try to figure out what was actually causing the order to be rejected before I found that it was the mrequest.comment line! (who could guess!)
So I just put the mrequest.comment line exactly like it was in the EA from the broker and the order actually went through!
Ty for the support guys!
You need to add a comment for an order request to work ? What's that !!!
Which comment by the way ?
You need to add a comment for an order request to work ? What's that !!!
Which comment by the way ?
Exactly!!! I would never have figured out that if I didn't try everything!!
the line is mrequest.comment="Turbo"; (Turbo is the name of the EA that the broker offers) (if I remove that line, the same error will appear again)
My guess is that my broker didn't want inexperienced users to use random EA's out there so they restricted the EA with that requirement, idk. (they are still working on the demo account thing and didn't release demo accounts yet)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The code works in strategy tester, but when using in real trade, I get Error 4756 (Trade request sending failed) and retcode 10006 (Request rejected).
Anyone has any idea why this could not work? the SYMBOL_FILLING_MODE is 3 and the SYMBOL_EXPIRATION_MODE is 2. I can buy and sell normally if I use the "new order" thing from Metatrader. Please, any idea would be greatly appreciated. I ran out of ideas I could try to make it work.
this will generate in log the following lines:
11:36:36.695 Trades '1000015025': exchange buy 1.00 WDON15 at market
11:36:36.763 Trades '1000015025': rejected exchange buy 1.00 WDON15 at market
if I use the "new order" tool from Metatrader (that works), it generates these lines:
11:09:31.155 Trades '1000015025': exchange buy 1.00 WDON15 at market
11:09:31.207 Trades '1000015025': exchange buy 1.00 WDON15 at market placed for execution in 51 ms (Order received. Sending to OMS.)
11:09:32.459 Trades '1000015025': deal #4204115 buy 1.00 WDON15 at 3129.000 done (based on order #4913284)
Thanks