Close Order issue
Yellowbeard,
Let's do some internal diagnostics and see if we can figure out what's going on.
Put a print statement in your code as follows and then let me see your log printout.
if(ordertype == "OP_SELL")
{
Print("OrderTicket = ",OrderTicket()," Lot = ",Lot," Ask = ",Ask);
OrderClose(OrderTicket(),Lot,Ask,2);
Print("Open Orders = ",OrdersTotal());
}
amended post: I just saw your other post where you indicated you had placed several print statements. I added a second print statement to see what it says after the order is suppose to be closed. You my have have to add "return(0)" inside the conditional-if so the EA returns for a new tick before attempting to open a new order.
cheers
Does anyone have an idea why my orders aren't closing when the log says they are?
.
.
11:29:36 ZEME EURUSD,M1: Alert: Attempt to open Sell
11:29:40 ZEME EURUSD,M1: open #8671746 sell 1.00 EURUSD at 1.42182 tp: 1.42152 ok
11:29:40 ZEME EURUSD,M1: Alert: Opened - Sell Order 8671746
11:29:40 ZEME EURUSD,M1: Alert: Error: 0
.
.
.
11:30:17 ZEME EURUSD,M1: Alert: POS A - Open order type is: 1 Ticket# 8671746
.
11:30:17 ZEME EURUSD,M1: Alert: Attempt to close Sell 8671746.
11:30:17 ZEME EURUSD,M1: Alert: Closed - Sell Order 8671746
11:30:17 ZEME EURUSD,M1: Alert: Error: 4105
.
11:30:17 ZEME EURUSD,M1: Alert: POS CA - Open order type is: 1 Ticket# 8671746
.
11:30:19 ZEME EURUSD,M1: Alert: Opened - Buy Order -1
11:30:19 ZEME EURUSD,M1: Alert: Error: 149
.
//---------------------------------- CLOSE SELL --------------------------------
.
RefreshRates();
OrderSelect(0,SELECT_BY_POS);
if(ordertype == "OP_SELL")
{OrderClose(OrderTicket(),Lot,Ask,2);}
{Alert ("Closed - Sell Order ",Ticket);}
Alert (GetLastError());
if(OrdersTotal()>0)
{Alert(" POS CA - Open order type is: ",OrderType()," Ticket# ",OrderTicket());}
//------------------------------------ SEND BUY --------------------------
if(OrdersTotal()== 0)
Alert("Attempt to close Buy ",Ticket);
{RefreshRates();
Ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,2,0,TakePB);}
//------------------------------------------------------------------------
Alert ("Opened - Buy Order ",Ticket);
Alert (GetLastError());