how to make sure to close order on MT3

 
Dear all,

I am using FxDirectDealer is based on MT3. My expert advisor want to close the buy trade at the specific open price.

1. Does the CloseOrde have a return value on MT3? So we could know if the open order has been closed or not?
2. Can we CloseOrder with current market price?
3. If we can not use a close order to close the buy order, can we use the SellOrder(OP_SELLSTOP) with a higher than current market stop price to garunteen that we close the buy order?

Thanks a lot!!!
 
Please help me...

Is there any way that we could open/close order with market price?
 
I have the following code to manage my open trades in MT3. So far no problem, and functioning well. Hope this helps:

=================================================================
For cnt=1 to TotalTrades
{
mode=OrderValue(cnt,VAL_TYPE);
If mode=OP_BUY then
{
If (Bid-OrderValue(cnt,VAL_OPENPRICE))>(TS) then
{
If OrderValue(cnt,VAL_STOPLOSS)<(Bid-TS) then
{
ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),
Bid-TS,OrderValue(cnt,VAL_TAKEPROFIT),Yellow);
Exit;
};
};
};
If mode=OP_SELL then
{
If (OrderValue(cnt,VAL_OPENPRICE)-Ask)>(TS) then
{
If OrderValue(cnt,VAL_STOPLOSS)>(Ask+TS) then
{
ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),
Ask+TS,OrderValue(cnt,VAL_TAKEPROFIT),White);
Exit;
};
};
};

If mode>OP_SELL then
{
// check how long it exists in the trading terminal. Time is counted in seconds:
// 10 minutes = 600 seconds, 30 minutes = 1800, 1 hour = 3600, 1 day = 86400
If (Minute>58) then
{
DeleteOrder(OrderValue(cnt,VAL_TICKET),RED);
Exit;
};
};

=============================================================
 
Thanks for your reply.

Do we have any easy way to open/close as market order instead of ModifyOrder and delete order?
 
Sorry, perhaps I misunderstood. The above logic is to manage open orders by modifying the SL/TP level, i.e., trailing stops, or deleting an open orders which have been pending for 1hr. If you want to open/close order, simply use SetOrder/CloseOrder commands.