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.
int OnInit()
{
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
}
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);
}
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