Just found the problem. I am attaching the EA to an EUR/USD chart and the order that I want to close is a USD/CAD order. So the Ask returned is the Ask price for EUR/USD, not USD/CAD.
Is there anyway I can close an order at any price immediately even the EA is attached to another symbol?
Thanks!
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID+OrderType()),3,CLR_NONE); // for Buy or Sell orders
Thank you Ray, I wish I had your vast knowledge of MT4 and computing. Take care.
Learn by doing
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
Hi, I want to close an order either BUY or SELL at current price, but I use the following function in vain. Please help.
OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE); // This is for SELL orders
OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE); // This is for BUY orders
When I ran this function, it returns a 129 errir which is wrong price.
Thanks.