Color Bars

This script colors a bar when two consecutive bars  produce the following:

1. The high on the second bar exceeds the low on the previous bar by a certain number. 
2. The flip version of this where the low on the second bar drops from the high of the previous bar by a certain number.

procedure ColorBar41;
var
  l1,l2,l3,h1,h2,h3: real;
  w: integer;
begin
  for w:=BarBeginLeft to BarEnd do
    if w>2 then begin
      l1:=Low(w); l2:=Low(w-1); l3:=Low(w-2);
      h1:=High(w);h2:=High(w-1);h3:=High(w-2);
      if (l1<l2-20) and (l2<l3-20) then SetBar(eColor,w,clRed);
      if (h1>h2+20) and (h2>h3+20) then SetBar(eColor,w,clGreen);
    end;
end;

begin
  if Who=41 then ColorBar41;
end;

To use, display a chart and then click the Color Bars button and click the #1 button on the bottom of the drop down panel.