
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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