if(buy_sign!=sell_sign && PositionSelect(Symbol())==0 && OrderCheck(request,resultCheck)) { OrderSend(request,result); Print("problem in sending an order!!"); Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode); }
}
But I have this warning from compiler: "return value of 'OrderSend' should be checked " referring to line 'OrderSend(request,result);' and this message from execution:
It works. But there is something strange that it is not clear:
2016.12.2712:00:03.0202016.01.0401:26:03 instant sell 0.10 EURUSD at 1.08464 sl: 1.08964 tp: 1.08164 (1.08464 / 1.08471 / 1.08464) 2016.12.2712:00:03.0202016.01.0401:26:03 deal #2sell 0.10 EURUSD at 1.08464 done (based on order #2) 2016.12.2712:00:03.0202016.01.0401:26:03 deal performed [#2sell 0.10 EURUSD at 1.08464] 2016.12.2712:00:03.0202016.01.0401:26:03 order performed sell 0.10 at 1.08464 [#2sell 0.10 EURUSD at 1.08464] 2016.12.2712:00:03.0272016.01.0401:26:03OnTick: Request executed reply code 10009 2016.12.2712:01:38.2252016.01.0407:36:29 stop loss triggered #2sell 0.10 EURUSD 1.08464 sl: 1.08964 tp: 1.08164 [#3buy 0.10 EURUSD at 1.08964] 2016.12.2712:01:38.2252016.01.0407:36:29 deal #3buy 0.10 EURUSD at 1.08965 done (based on order #3) 2016.12.2712:01:38.2252016.01.0407:36:29 deal performed [#3buy 0.10 EURUSD at 1.08965] 2016.12.2712:01:38.2252016.01.0407:36:29 order performed buy 0.10 at 1.08965 [#3buy 0.10 EURUSD at 1.08964]
As you can see, it perform a buy operation after getting the stop loss. Why is there this operation?
It is not clear if the 'buy operation' is performed or not. On the tab Operations, I have only :
Time
Ticket
Symbol
Action
Type
Volume
Price
S/L
T/P
Comment
2016.01.04 01:26:03
2
eurusd
instant
sell
0.1
1.08464
1.08964
1.08164
It's a simulation starting from the 1st January 2016.
While on History tab I have this situation:
Time
Order
Symbol
Type
Volume
Price
S/L
T/P
Time
State
Comment
2016.01.04 01:26:03
2
eurusd
sell
0.1/0.1
1.08464
1.08964
1.08164
2016.01.04 01:26:03
filled
2016.01.04 07:36:29
3
eurusd
buy
0.1/0.1
1.08964
2016.01.04 07:36:29
filled
sl 1.08964
Thus, I don't understand why there is a buy operation, if effectively there is.
Actually I very new to Metatrader, so sorry if I don't understand well also the GUI.
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.
Show your last code.
I understood that, and I fixed adding this line
request.volume=0.1;
But now I get that:
2016.12.21 18:16:24.918 2016.01.04 01:26:09 failed instant sell 0.10 EURUSD at 1.08463 sl: 1.08957 tp: 1.08155 [Invalid request]
Why is the request invalid? Where is the problem?
Thanks again for all support
Thanks
failed instant sell 0.10 EURUSD at 1.08463 sl: 1.08957 tp: 1.08155 [Invalid request] = You use the Ask price for a sell order
you can read this document to solve your problem
Thanks for all replies.
{
buy_sign=true;
take_profit=0.6*SymbolInfoDouble(_Symbol,SYMBOL_LAST)+SymbolInfoDouble(_Symbol,SYMBOL_LAST);
stop_loss=SymbolInfoDouble(_Symbol,SYMBOL_LAST);
loss_risk=0.03*AccountInfoDouble(ACCOUNT_MARGIN_FREE)*(SymbolInfoDouble(_Symbol,SYMBOL_LAST)-stop_loss);
profit_risk=0.03*AccountInfoDouble(ACCOUNT_MARGIN_FREE)*(take_profit-SymbolInfoDouble(_Symbol,SYMBOL_LAST));
request.type=ORDER_TYPE_SELL;
request.price=SymbolInfoDouble(Symbol(),SYMBOL_BID);
}
request.action=TRADE_ACTION_DEAL;
request.symbol=Symbol();
request.volume=0.1;
request.type_filling=ORDER_FILLING_FOK;
request.sl=NormalizeDouble(stop_loss,Digits());
request.tp=NormalizeDouble(take_profit,Digits());
if(buy_sign!=sell_sign && PositionSelect(Symbol())==0 && OrderCheck(request,resultCheck))
{
OrderSend(request,result);
Print("problem in sending an order!!");
Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode);
}
}
But I have this warning from compiler: "return value of 'OrderSend' should be checked " referring to line 'OrderSend(request,result);' and this message from execution:
" 2016.12.27 10:30:57.177 2016.01.04 01:26:03 failed instant sell 0.10 EURUSD at 1.08464 sl: 1.08964 tp: 1.08164 [Invalid request]
2016.12.27 10:31:00.656 2016.01.04 01:26:03 OnTick: Invalid request reply code 10013 "
Where is the problem now?
Thanks again
Ok thanks.
It works. But there is something strange that it is not clear:
2016.12.27 12:00:03.020 2016.01.04 01:26:03 deal #2 sell 0.10 EURUSD at 1.08464 done (based on order #2)
2016.12.27 12:00:03.020 2016.01.04 01:26:03 deal performed [#2 sell 0.10 EURUSD at 1.08464]
2016.12.27 12:00:03.020 2016.01.04 01:26:03 order performed sell 0.10 at 1.08464 [#2 sell 0.10 EURUSD at 1.08464]
2016.12.27 12:00:03.027 2016.01.04 01:26:03 OnTick: Request executed reply code 10009
2016.12.27 12:01:38.225 2016.01.04 07:36:29 stop loss triggered #2 sell 0.10 EURUSD 1.08464 sl: 1.08964 tp: 1.08164 [#3 buy 0.10 EURUSD at 1.08964]
2016.12.27 12:01:38.225 2016.01.04 07:36:29 deal #3 buy 0.10 EURUSD at 1.08965 done (based on order #3)
2016.12.27 12:01:38.225 2016.01.04 07:36:29 deal performed [#3 buy 0.10 EURUSD at 1.08965]
2016.12.27 12:01:38.225 2016.01.04 07:36:29 order performed buy 0.10 at 1.08965 [#3 buy 0.10 EURUSD at 1.08964]
As you can see, it perform a buy operation after getting the stop loss. Why is there this operation?
It is not clear if the 'buy operation' is performed or not. On the tab Operations, I have only :
It's a simulation starting from the 1st January 2016.
While on History tab I have this situation:
Thus, I don't understand why there is a buy operation, if effectively there is.
Actually I very new to Metatrader, so sorry if I don't understand well also the GUI.
Thanks