This procedure runs every time when an order is created, executed/removed or modified.
The procedure OnOrderChange has 2 parameters:
1) | Action: TDataModificationType – the type of change |
a) dmtInsert – an order is placed
b) dmtDelete – an order is executed/removed
c) dmtUpdate – an order is modified
2) | Order: TOrder – the object from the TOrder class that was affected by the change. |
The objects Action and Order can be accessed within the procedure.
Example:
Let us write a strategy that will output all the changes that take place in the Order Window into the log.
The script will be as follows:
Const StrategyName='My Strategy';
procedure OnOrderChange(const Action: TDataModificationType; const Order: TOrder); begin Log('Some Changes were made in orders table.'); Log('Action: ' + IntToStr(Action)); Log('Order: ' + Order.Id); Log('Instrument: ' + Order.Instrument.Name); Log('Account: ' + Order.Account.Id); Log('Order Tag: ' + Order.Tag); end; |
As a result, the procedure OnOrderChange will run every time any change occurs in the Order Window, and the information about the modified/removed/placed order will appear in the log.
As a result, the output may look something like this: