| / | Forum |
|
pisceswzh
2008.11.05 07:51
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. |
|
Testing and Optimizing Expert Advisors We decided to draw your attention to this problem once again and asked well-known Expert Advisors writer for sharing their experiences in this field. |
|
pisceswzh
2008.11.05 08:20
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! |
|
sxTed
2008.11.05 10:22
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID+OrderType()),3,CLR_NONE); // for Buy or Sell orders
|
|
phy
2008.11.05 10:28
Oh, I like the MODE_BID+OrderType()... That hadn't occurred to me.
|
|
sxTed
2008.11.05 10:40
Thank you Ray, I wish I had your vast knowledge of MT4 and computing. Take care.
|
|
phy
2008.11.05 10:43
Learn by doing |