Account Charts

This example will read a trading account file and display a chart for the open positions.  The trading account files are stored in the C:\Ensign\Accounts folder, and are numbered beginning with 1.  Our example will work with the first trading account.

var
  i: integer;
  s,symbol,exitdate: string;
begin
  Output(eClear);
  mnuCloseAllWindows.click;
  sList.LoadFromFile(sPath+'Accounts\Account.1');
  for i:=0 to pred(sList.Count) do begin
    s:=sList.strings[i];
    writeln(s);
    exitdate:=Trim(GetToken(8,s,#44));
    if length(exitdate)=0 then begin
      symbol:=Trim(GetToken(3,s,#44));
      if length(symbol)>0 then Chart(symbol);
    end;
  end;
  mnuTileVertical.click;
end;

Notes:  The first thing we do is clear the Output window and close all open windows.

The account file is ASCII text that we load into a predefined string list variable sList.  Each record of the file is displayed in the Output window.  The writeln(s) is not necessary, but it is informative for those who might want to do more with this example.

We use GetToken to read the exit date from the 8th field in the comma delimited record.

For Open positions, the exit date field will be blank.

We use GetToken to read the symbol from the 3rd field, and display a chart for valid symbols.  After displaying charts for all open positions, the charts are tiled vertically.

This is another example of the power of ESPL reducing a task to a few statements.  I hope these examples increase your awareness of powerful tools like string lists, GetToken, Trim, and menu clicks.