Top 50 Volumes

This example will display the top 50 volumes from any chart.  With a chart displaying, click on the #5 button on the Script Editor's button panel to execute.  An array is created for a workspace and to have access to its Sort method. For each bar on the chart, its volume value is transferred to the array.  The array is sorted in descending order.  The first 50 entries in the array are printed to the Output window.  Last of all, don't forget to free the array after using it.

Use this example with a Tick chart to print the highest tick volumes.

var
  i: integer;
  v: TArray;
begin
  if who=5 then
    if FindWindow(eChart)>0 then begin
      Output(eClear);
      v:=TArray.Create;
      for i:=1 to BarEnd do v.Values[i]:=Bar(eVolume,i);
      v.Sort(BarEnd,BarEnd,False);
      for i:=1 to 50 do writeln(v.Values[i]);
      v.free;
    end;
end;