The procedure OnAccountChange(const Action: TdataModificationType; const Account: TAccount)

This procedure runs when the following occurs in any of the trader's accounts: balance change, group account changes, default amount change, markups adjustment.

The procedure OnAccountChange has two parameters:

1)Action: TDataModificationType – the type of change:

a) dmtUpdate - balance change, group account changes, default amount change, markups adjustment

2)Account: TAccount – the object from the TAccount class that was affected by the change.

 

The objects Action and Account can be accessed within the procedure.

 

Example:

Let us write a strategy that will output all the changes that take place in the Account Information Window into the log.

The script will be as follows:

 

Const

   StrategyName='My Strategy';

 

procedure OnAccountChange(const Action: TDataModificationType; const Account: TAccount);

begin

 Log('Some Changes were made in accounts table.');

 Log('Action: ' + IntToStr(Action));

 Log('Account: ' + Account.Id);

 Log('Balance: ' + FloatToStr(Account.Balance));

 Log('Equity: ' + FloatToStr(Account.Equity));

end;

 

As a result, the procedure OnAccountChange will run every time any change occurs in the Account Information Window, and the information about the changed account will appear in the log.

As a result, the output may look something like this:

 

ribbonactfx104