PureBytes Links
Trading Reference Links
|
> I would like to plot a showme on every bar following a bar that
> has met some criteria (Just once) until another criteria is met.
You don't need to use looping. Just use the bar-to-bar memory of
variables inherent in EL.
The following code plots a ShowMe dot at the High of each bar after
Close exceeds the top BBand, and turns it off when the close goes
below the average (center of the BBand), and vice-versa for the
bottom BBand.
(I didn't attempt to make it efficient, e.g. I called average()
twice. If you really wanted to make it efficient, you'd call
average() once, StdDev() once, and calculate the BBands yourself with
avg+2*SD, avg-2*SD.)
Gary
Inputs: BBlen(20);
Vars: UpBB(0), DnBB(0), HitUp(False), HitDn(False);
UpBB = BollingerBand(Close, BBlen, +2);
DnBB = BollingerBand(Close, BBlen, -2);
if (Close > UpBB) then HitUp = True;
if (Close < average(Close, BBlen)) then HitUp = False;
if (Close < DnBB) then HitDn = True;
if (Close > average(Close, BBlen)) then HitDn = False;
if HitUp then plot1(High, "Up");
if HitDn then plot2(Low, "Dn");
|