You need to check the return value of OrderSend() / OrderCLose() functions.
Analyze what they return to see if the call was successful or not, and if not take action on that.
Look at examples in CodeBase.Yes that's exactly what I am doing ... basically I increase the slippage by 1 and try one more time until I success...
but what if I want to place the order with current market price any way.... or what if I want to close a position no matter what the current price is....
how could I implement such logic?
I will check the CodeBase anyway.
Once again thanks for the input.
No it's not if your price is off your code will get stuck in an endless do loop and flood the server and it will block and disconnect your terminal connection.
You can see code base for examples.
Hello friend, I am not sure that you realize this, but you haven't filled in the required fields correctly.
int position=OrderSend(NULL,OP_BUY,0.01,Ask,3,0,0,"Place order",0,0,clrGreen); if(position<0) { Alert("Order Failed); } else Alert("Order Placed"); }
Good luck
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear All,
It has been 3-4 weeks since I started coding in mq4.
I have developed an EA which creates buy/sell orders. I used slippage = 3, but, since I used to get error 138 reqoute most of the time I came up with below idea for both ordersend and orderclose as attached:
I would like an expert to comment on my thoughts.
Thank you in advance: