Stock Filter

Let's create a custom quote page of Nasdaq stock symbols which match the following criteria:
  1. price is in the upper 90% of today's trading range,
  2. net is up at least 50 cents,
  3. today's volume is at least 10,000 shares.

Last of all, sort the list by volume in descending order.  Several power ESPL functions make this a fairly easy task.  We are having these lessons because an example is a great teacher.  Once you see how the script is written, it is hoped you can adapt it to serve your specific interests.

Cut the script from this page and paste it in the ESPL Script Editor window.  Click on button #5 on the script editor to execute.

var i: integer;
begin
  if who=5 then begin
    Output(eClear);
    if Find(eNasdaq) then repeat
      if Filter(ePercent,90,100, eNet,50,999999, eVolume,10000,999999999) then
        writeln(GetData(eMarketID),
          Align(GetData(eSymbol),10,eLeft),
          Align(GetData(eVolume)));
    until not Find(eNext);
    Output(eSort,12,false);
    Output(eSave,'Stock.quo');
    sList.LoadFromFile(sPath+'Stock.quo');
    for i:=0 to pred(sList.count) do
      sList.strings[i]:=TrimRight(Copy(sList.Strings[i],1,11));
    sList.SaveToFile(sPath+'Stock.quo');
    Quote(eCustom,'Stock');
  end;
end;

Notes:  The test of who=5 causes this script to execute when the #5 button is clicked.

The Find(eNasdaq) repeat...until statements cycle through every symbol in the Nasdaq database.

The Filter function implements the three tests in our criteria.

The writeln statement prints the symbols and the volume aligned in columns in the Output window.

The Output(eSort function sorts the data by volume in descending order.

The Ouput(eSave writes the data to a file, but we still need to strip off the volume information.  Therefore, the file is read into a string list so it can be manipulated.

The for loop extracts just the symbol portion of each line, and the string list is resaved to the file.

The Quote function will load and display our sorted custom quote list.

If you do not understand a particular function, then please consult the ESPL Help documentation for the function.  The basics of what is being done for the database scan is discussed in greater detail in the documentation as 'Writing a Database Scan' example.