waterhorse:
I am using the below example code from Metaquote; however, I am getting the message [Position already closed] and it would not enter the Stop Loss and Take Profit for my order. Below is my screen capture of the Trade Journal.
...
if (OrderSend(mrequest, mresult)==true)
- You have to check the return code of mresult. OrderSend returning true is not enough, see documentation :
Return Value
In case of a successful basic check of structures (index checking) returns true. However, this is not a sign of successful execution of a trade operation. For a more detailed description of the function execution result, analyze the fields of result structure.
- You have a synchronisation issue, there are several ways to manage that. See this topic : https://www.mql5.com/en/forum/11051
- You don't need to send SL/TP after the order is open, set your SL/TP with your order.
angevoyageur:
Thanks Alain for you help. I did a quickfix for now i.e. Sleep(1000); before modifying the SL and TP and it seems to be OK.
- You have to check the return code of mresult. OrderSend returning true is not enough, see documentation :
- You have a synchronisation issue, there are several ways to manage that. See this topic : https://www.mql5.com/en/forum/11051
- You don't need to send SL/TP after the order is open, set your SL/TP with your order.
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
I am using the below example code from Metaquote; however, I am getting the message [Position already closed] and it would not enter the Stop Loss and Take Profit for my order. Below is my screen capture of the Trade Journal.
sOP = "BUY";
clOP = Aqua;
l_cmd_36 =0;
getT2 = ORDER_TYPE_BUY;
l_price_0 = b1_symbol.Ask();
l_price_8 = Ask - (b1_sl*b1_symbol.Point());
l_price_16 = Ask + (b1_tp*b1_symbol.Point());
bool result = OrderSendMQ4(b1_symbol.Name(), l_cmd_36, OrderSize(), l_price_0, Slippage, l_price_8, l_price_16, sOP, Magic1);