The TOrder.Remove Method

The Remove method of TOrder objects allows you to remove orders. This method does not have any parameters.  For example, you have an object Ordr:TOrder, that holds an order. To remove it, you need the following line:

 

Ordr.Remove;

 

Example1: Let us create a strategy that will remove all the orders.

 

const

 StrategyName = 'Orders';

 

procedure OnStart;

var i: Integer;

begin

for i:= OrderList.Count-1 downto 0 do

   begin

   if OrderList.Count>0 then

      OrderList.Get(i).Remove;

   end;

end;


 

Example2: Let us create a strategy that will remove all the stops and limits on the open positions.

 

const

 StrategyName = 'Orders';

 

procedure OnStart;

var i: Integer;

begin

for i:= TradeList.Count-1 downto 0 do

    begin

      if TradeList.Get(i).LimitOrder <> nil then TradeList.Get(i).LimitOrder.Remove;

       if TradeList.Get(i).StopOrder <> nil then TradeList.Get(i).StopOrder.Remove;

    end;

end;