Top 100 Symbols
Here is a script that displays charts from a list of symbols on a quote
page. This is a really neat script that many of you will want to add
to your library of examples. An explanation follows the script.
procedure ChangeTime(s: string);
var
i: integer;
f,p: TForm;
begin
window:=1; p:=Self;
for i:=0 to pred(MDIChildCount) do begin
f:=ActiveMDIChild;
if Copy(f.name,1,8)='frmChart' then SendKeys(s);
application.processmessages;
p.Next;
end;
end;
procedure ChangeSet(w: word);
var
i,j,k,count,offset: integer;
s: string;
f,p: TForm;
begin
{find open quote page}
if FindWindow(eQuote)>0 then begin
{count how many chart windows are
open}
count:=0;
for i:=0 to pred(MDIChildCount) do begin
f:=screen.forms[i];
if Copy(f.name,1,8)='frmChart' then inc(count);
end;
{compute offset in quote page, 1st set,
2nd set, etc}
if w=0 then inc(w);
offset:=count*pred(w);
{read quote page symbols}
sList.clear;
for i:=1 to count do sList.Add(GetCell(offset+i,0));
{loop through windows, apply symbols
to charts}
p:=Self; j:=0;
for i:=0 to pred(MDIChildCount) do begin
f:=ActiveMDIChild; window:=1;
if Copy(f.name,1,8)='frmChart' then begin
{get current
charts extension such as D for daily}
s:=GetToken(2,GetVariable(eName),'.');
ChartReplace(sList.strings[j]+'.'+s);
inc(j);
end;
application.processmessages;
p.Next;
end;
end;
end;
begin
if KeyDown(2) then ChangeSet(who)
else begin
if who=1 then ChangeTime('1');
if who=5 then ChangeTime('5');
end;
end;
This is how you use it. A left click on #1 menu will change all
open charts to a 1-minute time frame.
Now, if you hold down the right mouse button when you left click on the #1
menu, the symbols on all open charts will change to the 1st set of symbols in
sequence on your open quote page. The script is self
adjusting. If you have 5 charts open, the symbol set will be the 1st five
symbols on your quote page. If you hold the right mouse button down,
and left click on the #2 menu, the 2nd set of 5 symbols from the quote page will
be used. Since I use the Who value to select the symbol set, menu #1
through #9 will select the 1st through 9th symbol set. The symbol set size
is controlled by the number of windows that are open.
A slick use for this script is display a quote page, such as NYSE and use the
Top100 to obtain a list of 100 symbols. Then use this script to open
charts for the 1st, 2nd, or 3rd (etc.) set of symbols from the Top100 list.
The ChangeSet routine reads the symbols from the quote page and uses
them to replace the charts. There are comments showing the breakdown
of each step in the process.
|