im having problems getting pending orders (i.e buystop / sellstop) to delete when another order (buy / sell) is opened.
Code: Select all
// Delete any pending orders if order is opened
if (OrdersTotal > 0) then
begin
for i:=0 to OrdersTotal do
begin
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType = tp_SellStop) then DeleteOrder(i);
if (OrderType = tp_BuyStop) then DeleteOrder(i);
end;
end;
in the journal it keeps posting can not find order - so therefore I assume im not selecting the order correctly. Anyone got any hints?