ActFX enables the user to directly input specific commands which can affect the strategy that is being executed. Those can be used to place an order, close a position, make a record in the log etc.
This procedure is used to define the custom commands that can be used during the strategy execution.
Example:
Let us write a strategy that will output the used account number into the log, when we type 'acc' in the command line.
The script will be as follows:
const StrategyName = 'My Strategy';
------------------------------------------------------
procedure OnCommand(const Command: String); begin if Command = 'acc' then log ('Account number: ' +Account.Id); end; |
The command line is located in the very bottom of the strategy window.
Example 2:
Let us write a strategy that will assign the value that we type in the Command line to the variable Amount. For instance, if we type '3' in the command line, the variable Amount will change its value to 3.
The script will be as follows:
Const StrategyName='My Strategy'; var Amount: Integer;
procedure OnCreate; begin AddIntegerSetting(@Amount, 'Amount(Lots)', 1); end;
procedure OnCommand(const Command: String); begin Amount:=StrToInt(Command); end; |
As a result, every time we click 'Send Command', the procedure OnCommand (const Command:String) will run, and transmit the value in the command line as a parameter. Please note that the Command parameter transmitted into the procedure is of the string type; therefore it should be converted into the needed type.