Color Bars

This script will paint a color bar when 2 conditions are met:

1. This bar's low is the lowest of last 5 bar's lows
2. This bar has closed above the previous bar's close.

If both conditions are true, paint this bar green.

And the converse for a sell (i.e. highest of last 5 bar highs, close below previous bar's close, paint bar red)

Cut the script from this example and paste it into the script editor, and save it to a file you name.

To use, display a chart, and then select the Color Bar button, and on the drop down panel select the #3 button.  This will add a user defined color bar study to the chart, which will call the script with Who=43 which we test for and execute the logic.

var i,barindex: integer;
begin
  if Who=43 then for i:=BarBeginLeft to BarEnd do begin
    if Bar(eNet,i)>0 then begin
      if Lowest(eLow,i,5,BarIndex,1,0)=Low(i) then SetBar(eColor,i,clLime);
    end
    else begin
      if Highest(eHigh,i,5,BarIndex,1,0)=High(i) then SetBar(eColor,i,clRed);
    end;
  end;   
end;