Order Actions

hmtoggle_plus1TOrder.Modify

The Modify method of TOrder objects allows you to make changes to existing conditional orders. It has 2 parameters:

 

 1. Rate : TTrade –  the modified order rate.

 2. Amount: Double — the modified number of lots.

 

Note that for Stop and Limit orders Amount value is disregarded (as it cannot be changed). You still have to input some value, although it will not be used.

 

Example:

 

You have an object Ordr: TOrder, that holds an order. To modify this order, you need the following line:

 

Ordr.Modify(1.6250,3);

 

The order rate will be changed to 1.6250, and the Amount will be changed to 3.

 

Example: Let us create a strategy that will shift the rate of every order in the order list 2 points down, and change the Amount into 3.

 

const

 StrategyName = 'Orders';

 StrategyVersion = '1.0';

 

procedure OnStart;

var

 i: Integer;

begin

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

   OrderList.Get(i).Modify(OrderList.Get(i).Rate – 2*OrderList.Get(i).Instrument.PointSize, 3);

end;

 

hmtoggle_plus1TOrder.Remove

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';

 StrategyVersion = '1.0';

 

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';

 StrategyVersion = '1.0';

 

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;

 

hmtoggle_plus1TOrder.Comment and TTrade.Comment

The Comment method of TOrder and TTrade properties allows you to add/modify Comments in the Orders, Open Positions and Closed positions windows:

 

OrderList.get(0).comment := ’Comment text’;  // add comment to the order

 

TradeList.get(0).comment := ’Comment text’;  // add comment to the Trade

 

In order to view Comments in the Orders, Open Positions and Closed positions windows, use the following commands:

 

S := OrderList.get(0).comment; // S-string, return comment of the order or empty value

 

S := TradeList.get(0).comment; // S-string,  return comment of the trade or empty value

 

In order to delete Comments in Orders, Open Positions and Closed positions windows use these commands:

 

OrderList.get(0).comment:=’’; // remove comment of the order 

 

TradeList.get(0).comment:= ’’; // remove comment of the trade

Show/Hide Hidden Text