Color Bars
This script that colors bars based on Net and leaves the unchanged bars
yellow. I went ahead and added the code necessary to give you an
Alert when you have a sequence of unchanged bars. Now that the
script is written, I am sure you can read follow along with the script's logic
and make adjustments to the script to make it work the way you have in
mind.
var i,j: integer;
begin
if who=41 then begin
j:=GetVariable(eCommission);
for i:=BarBegin to BarEnd do begin
if Bar(eNet,i)>0 then SetBar(eColor,i,1);
if Bar(eNet,i)<0 then SetBar(eColor,i,2);
if Bar(eNet,i)=0 then inc(j) else j:=0;
if (j=3) and (i=BarEnd) then
Alert(True, 'Place Order Alert',
clRed, clWhite, '');
end;
SetVariable(eCommission,j);
end;
end;
The one item that might need explaining is the use of the GetVariable/SetVariable
operating on the chart's Commission variable. We need a place to
store the counter J in between executions. Since this script might
be used by multiple charts simultaneously, this counter needs to be preserved
between calls. The counter is the trigger to when an alert should be
shown. Commission is probably not needed by your scripts, which
makes it available as storage for our script counter J.
To use this script, cut and paste it into the script editor and save it under
a useful name. Display your chart, and click the #1 button on the
Color Bar drop down panel. This will dress the chart using a
user defined color bar, and the script will be called with the Who variable
having a value of 41 to do the bar coloring.
|