mrequest.type_filling = ORDER_FILLING_IOC; //ORDER_FILLING_FOK; // Order execution type
Why is it like that ?
#define EXPERT_MAGIC 123456// MagicNumber of the expert//+------------------------------------------------------------------+//| Opening Buy position |//+------------------------------------------------------------------+voidOnStart()
{
//--- declare and initialize the trade request and result of trade requestMqlTradeRequest request={0};
MqlTradeResult result={0};
//--- parameters of request
request.action =TRADE_ACTION_DEAL; // type of trade operation
request.symbol =Symbol(); // symbol
request.volume =0.1; // volume of 0.1 lot
request.type =ORDER_TYPE_BUY; // order type
request.price =SymbolInfoDouble(Symbol(),SYMBOL_ASK); // price for opening
request.deviation=5; // allowed deviation from the price
request.magic =EXPERT_MAGIC; // MagicNumber of the order//--- send the requestif(!OrderSend(request,result))
PrintFormat("OrderSend error %d",GetLastError()); // if unable to send the request, output the error code//--- information about the operationPrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
}
//+------------------------------------------------------------------+
Example of the TRADE_ACTION_DEAL trade operation for opening a Sell position:
#define EXPERT_MAGIC 123456// MagicNumber of the expert//+------------------------------------------------------------------+//| Opening Sell position |//+------------------------------------------------------------------+voidOnStart()
{
//--- declare and initialize the trade request and result of trade requestMqlTradeRequest request={0};
MqlTradeResult result={0};
//--- parameters of request
request.action =TRADE_ACTION_DEAL; // type of trade operation
request.symbol =Symbol(); // symbol
request.volume =0.2; // volume of 0.2 lot
request.type =ORDER_TYPE_SELL; // order type
request.price =SymbolInfoDouble(Symbol(),SYMBOL_BID); // price for opening
request.deviation=5; // allowed deviation from the price
request.magic =EXPERT_MAGIC; // MagicNumber of the order//--- send the requestif(!OrderSend(request,result))
PrintFormat("OrderSend error %d",GetLastError()); // if unable to send the request, output the error code//--- information about the operationPrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
}
//+------------------------------------------------------------------+
I read this topic https://www.mql5.com/en/forum/60690, and maybe I must add a comment to my order request too. But I don't know where can I find the keyword that I must to use?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I tested the last code on real account and got the same errors:
There is a problem here There is a problem hereee The Buy order request could not be completed -error:4756I also checked the journal tab and found the log:
Why is it like that ?
Try like these.
Why is it like that ?
Try like these.
What is the difference between OnTick() and OnStart() ?
Why is it like that ?
Try like these.
I tried your code but I get "4753" error!
I also tried to comment the filling_type code or test all the filling types methods. The only change happened when I used this code:
And got these new errors in journal tab:
2019.01.14 12:22:26.819 Trades '89412': accepted exchange buy 1.0K خساپا at market sl: 1297 tp: 1433
2019.01.14 12:22:26.828 Trades '89412': rejected exchange buy 1.0K خساپا at market sl: 1297 tp: 1433
check the return code of MqlTradeResult
I checked for retcode:
I checked for retcode: