The procedure OnStart

This procedure runs when you actually start executing(or testing) the strategy after you are done with adjusting or modifying all the settings. In other words, this procedure runs when you press 'Start Strategy'/'Test Strategy'.

 

ribbonactfx100

 

 

Example:

Let us write a script that will just output the selected settings into the log.

The script will be as follows:

 

Const

   StrategyName='My Strategy';

 

var

   History: TCandleHistory;

   Account: TAccount;

   StrSetting: String;

   IntSetting: Integer;

 

procedure OnCreate;

begin

   AddCandleHistorySetting(@History, 'Candle History', '', CI_5_Minutes, 100);

   AddAccountSetting(@Account, 'Account', '360');

   AddStringSetting(@StrSetting,  'String Setting',  'asd32');

   AddIntegerSetting(@IntSetting, 'Integer Setting', 20);

end;

 

procedure OnStart;

begin

   Log('Strategy Started with the following settings:');

   Log('Instrument: ' + History.Instrument.Name);

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

   Log('String setting: ' + StrSetting);

   Log('Integer Setting: ' + IntToStr(IntSetting));

end;

 

Assuming that we are using the default values, the result will be as follows:

 

ribbonactfx101

 

 

Note that in order to output data into the log, it must be of the string type. Therefore we used the IntToStr() function to convert integer type into the string type.

 

You can find the list of data types conversion functions in the Appendix section.