News Alert
I cleaned up your script by using some powerful built in ESPL statements you
were unfamiliar with. Here a better version for eSignal users:
function GetTime(s: string): longint;
begin
if length(s)=5 then begin
Delete(s,3,1); {remove colon}
result:=StrToInt(s);
end
else result:=0;
end;
function GetDate(sDate: string): longint;
begin
sDate:=Copy(sDate,1,2)+'/'+Copy(sDate,4,2);
result:=DateToLong(StrToDate(sDate)); {assume current year}
end;
procedure ColorAllBars;
var j,n,iBar,iTime,iDate: integer;
s: string;
begin
if FindWindow(eChart,'IBM.1') then
begin {find the chart}
n:=NewsFind('_IBM_');
{show just IBM headlines}
for j:=1 to n do begin
s:=NewsTitle(j);
{process each headline}
writeln(s);
{print in output window}
iTime := GetTime(GetToken(2,s,'
')); {extract Time in title}
iDate := GetDate(GetToken(1,s,'
')); {extract Date in title}
iBar := Bar(eIndex,iDate,iTime);
{find bar with this time stamp}
if iBar>0 then SetBar(eColor,iBar,clLime); {change its
color}
end;
end;
end;
procedure ColorBarOnNewsAlert; {process current headline}
begin
if pos('IBM',IT) then if FindWindow(eChart,'IBM.1') then
SetBar(eColor,BarEnd,clLime);
end;
{------------- MAIN -------------}
begin
if Who = 0 then begin
NewsSymbol('IBM',1,300);
{refresh today's IBM stories}
NewsAlert(eSet,'_IBM_');
{be sure IBM is news keyword}
AlertEvent(eNews,69);
{set event trigger for news}
end;
if Who = 1 then ColorAllBars;
{process past stories}
if Who =69 then ColorBarOnNewsAlert; {process
current story}
end;
The script can be used to color bars on a 1-minute chart for
IBM. Click the RUN button on the editor form to
perform the initialization of requesting a refresh of IBM headlines, adding
_IBM_ as a news alert keyword, and registering a News Alert event.
Click the 1 button on the editor form to color the IBM.1 chart bars based on
the arrival of past IBM stories. The Alert Event will color
the current bar if the headline contains IBM keyword.
|