PureBytes Links
Trading Reference Links
|
Another version!
Also, attached ELA.
----------------------------------------------------------
{Indicator - SafeZone}
{Alexander Elder's "SafeZone Stop"}
{Book "Come Into My Trading Room" page 173}
{Barry Silberman's version}
{Eric Svendsen, Programmer (858) 874-0328 }
inputs:
Length(15),
Trend(3),
MultipleLong(1),
MultipleShort(1),
XPrice((H+L)/2),
XLength(22);
vars:
XMA(0), Sum(0), Cnt(0),
LDay(0), LAve(0), LStop(0),
HDay(0), HAve(0), HStop(0),
SafeZone(0), SZColor(White),
i(0);
{Trend is slope of EMA}
XMA = XAverage(XPrice, XLength);
SafeZone = Close[1];
{SafeZone for Longs}
{TOTAL ALL VALUES OF LOWS BEING LOWER THAN PRIOR LOW}
{COUNT NUMBER OF DAYS WITH LOWS BEING LOWER THAN PRIOR LOW}
{GET AVERAGE OF LOWS LOWER THAN PRIOR LOW}
{CALCULATE STOP AT "X" TIMES AVGLOW}
{PREVENT STOP FROM BEING LOWERED}
if XMA > XMA[Trend] then
begin
for i = 1 to Length
begin
LDay = L[i] - L[i-1];
if LDay > 0 then
begin
SUM = SUM + LDay;
CNT = CNT +1;
end;
end;
if Cnt > 0 then LAve = Sum / Cnt;
LSTOP = LOW[1] - (MULTIPLELONG * LAve[1]);
SafeZone = MAXLIST(LSTOP, LSTOP[1], LSTOP[2], LSTOP[3], LSTOP[4],
LSTOP[5]);
end;
{SafeZone for SHORTS}
{TOTAL ALL VALUES OF HIGHS BEING HIGHER THAN PRIOR HIGH}
{COUNT NUMBER OF DAYS WITH HIGHS BEING HIGHER THAN PRIOR HIGH}
{GET AVERAGE OF HIGHS HIGHER THAN PRIOR HIGH}
{CALCULATE STOP AT "X" TIMES AVGHIGH}
{PREVENT STOP FROM RISING}
if XMA <= XMA[Trend] then
begin
for i = 1 to Length
begin
HDay = H[i-1] - H[i];
if HDay > 0 then
begin
SUM = SUM + HDay;
CNT = CNT +1;
end;
end;
if CNT > 0 then HAve = SUM / CNT;
HSTOP = HIGH[1] + (MULTIPLESHORT * HAve[1]);
SafeZone = MinList(HSTOP, HSTOP[1], HSTOP[2], HSTOP[3], HSTOP[4],
HSTOP[5]);
end;
{Colors for Fun}
SZColor = Red;
if XMA > XMA[Trend] then
SZColor = Green;
{Plot}
PLOT1(SafeZone, "SafeZone", SZColor);
{end}
Attachment:
Description: "SAFEZONE.ELA"
|