[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alexander Elder's "SafeZone Stop"



PureBytes Links

Trading Reference Links

John and Gary,

I don't see Dr. Elder specifically saying begin calculating  the LDay after
the trend change.   Rather he says you may use the slope of a 22 day EMA to
define the trend.   Dr. Elder also seems to emphasize the following:

1- SafeZone is not a mechanical gadget to replace independent thought.
2- Calculate the stops separately for uptrends and downtrends.
3- The lookback period should not go back beyond the last important turning
point.  If the market has reversed from down to up two weeks ago, then
SafeZone
     for the current long trades should not look back more than 10 trading
days.
4-  An important decision is choosing the coefficient for the SafeZone stop.
He says a coefficient between 2 and 3 provides a margin of safety, but you
must
      research it on your own market data.  Once you have done your homework
and tweaked  this indicator, it will become your own private tool ....
5-  You can add it to almost any trading system, including Triple Screen.
6-  The excel code that Dr. Elder used in his book kept the stop from
declining for 3 days, by which time either the uptrend resumes or the stop
is hit.   I used a
      period of 5, since I was interested in avoiding lowering my stop at
all.   (Opposite of course for shorts).

In the charts I have looked at I don't see a practical difference between
keeping the "If Condition2 then" or not, since one would be out of the trade
once the trend reversed.   If you think the usefulness of the indicator is
improved, then by all means let's change it.   Could you please show me a
chart in which the exit was affected by the change in code.

Regards,

Barry Silberman

----- Original Message -----
From: "John Lynch" <kiwi_trader@xxxxxxxxxxxx>
To: "Omega List" <omega-list@xxxxxxxxxx>; "Gary Fritz" <fritz@xxxxxxxx>;
"Barry Silberman" <barry@xxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, May 08, 2002 8:22 PM
Subject: Re: Alexander Elder's "SafeZone Stop"


> Thats nice code Gary.
>
> I agree that calculating LDay only after the start of the trend is causing
> the difference in the stop for the first couple of days of a new trend.
>
> Barry, If Dr Elder doesnt directly state that we should begin calculating
> the LDay after the trend change I'd support removing the "IF CONDITION2
> THEN" which will give the same result that Gary's code provides.  I've
> pasted an updated version below and attached it as an ela.  Apologies for
> the format of the comments below ... they're better in the ela.
>
> A question for Gary.  Do you know which approach is better wrt to speed of
> calculation?
>
> John
>
> ----- Original Message -----
> From: "Gary Fritz" <fritz@xxxxxxxx>
> To: "Barry Silberman" <barry@xxxxxxxxxxxxxxxxxxxxx>
> Cc: "Omega List" <omega-list@xxxxxxxxxx>
> Sent: Wednesday, May 08, 2002 6:31 AM
> Subject: RE: Alexander Elder's "SafeZone Stop"
>
>
> > The version below is a combination of the code John Lynch provided
> > to me privately for testing (which he has approved for posting to
> > the list) and some neat additions from Eric Svendesen, which he
> > previously provided to the list.   The array formula below gives
> > identical results to the "LONG" way of doing it.
>
> FWIW:  Here is a version that uses the TS variable history instead of
> arrays.
>
> This indicator's results are not quite identical to Barry's.  In
> particular, for a few bars after a trend change, this code produces
> slightly different results.  After a few bars, they match exactly.
>
> I don't have Elder's book, so I can't say for sure, but I suspect
> this code is more correct.  Both versions that Barry posted compute
> the LSTOP and SSTOP values on every bar -- which they must, in order
> for the 5-day min/max calculation to work correctly -- but they only
> compute the LDAY/SDAY values when the trend is right.  Which means
> that for the first few days after a trend change, the LSTOP/SSTOP
> calculations are using invalid values of LDAY/SDAY.
>
> Gary
>
> =====
>
>
> { Barry Silberman's version of Alexander Elder's "SafeZone Stop" from book
> "Come Into My Trading Room" page 173
> Amended by John Lynch 5/1 with Eric Svendsen's Coloured Stop and trend
> variable added 5/3}
>
> Inputs:
>  Price((H+L)/2 ), Length( 22), Lookback(15), trend(3),
>  MULTIPLELONG(1), MULTIPLESHORT(1), ColourShort(Red), ColourLong(Blue);
>
> Variables:
> MA(0),  LONGSUM(0),  SHORTSUM(0) , COUNTLONG(0), COUNTSHORT(0), AVGLOW(0),
> AVGHIGH(0), LONGSTOP(0), SHORTSTOP(0), LSTOP(0), SSTOP(0), ii(0);
>
> Arrays: Lday[30](0), Sday[30](0);
>
> {determine trend by slope of EMA}
> MA = xaverage( Price, Length );
> CONDITION1 = MA > MA[trend];
> CONDITION2 = MA < MA[trend];
>
> {SafeZone for Longs}
> LONGSUM = 0;
> COUNTLONG = 0;
> For ii=1 to Lookback Begin
>   Lday[ii]=IFF(L[ii]>L[ii-1],L[ii]-L[ii-1],0);
>   LONGSUM =LONGSUM + Lday[ii];
>    {TOTAL ALL VALUES OF LOWS BEING LOWER THAN PRIOR LOW}
>   COUNTLONG = COUNTLONG + IFF(Lday[ii]>0,1,0);
>    {COUNT NUMBER OF DAYS WITH LOWS BEING LOWER THAN PRIOR LOW}
>   End;
> IF COUNTLONG <> 0 THEN AVGLOW = LONGSUM / COUNTLONG;
>    {GET AVERAGE OF LOWS LOWER THAN PRIOR LOW}
> LSTOP = LOW[1] - (MULTIPLELONG * AVGLOW[1]);
>    {CALCULATE STOP AT "X" TIMES AVGLOW}
> LONGSTOP = MAXLIST(LSTOP, LSTOP[1], LSTOP[2], LSTOP[3], LSTOP[4],
LSTOP[5]);
> {PREVENT STOP FROM BEING LOWERED}
> IF CONDITION1 THEN PLOT1(LONGSTOP, "STOP", ColourLong);
>    {SET PLOT}
>
>
> {SafeZone for SHORTS}
> SHORTSUM = 0;
> COUNTSHORT = 0;
> For ii=1 to Lookback Begin
>   Sday[ii]=IFF(H[ii]<H[ii-1],H[ii-1]-H[ii],0);
>   SHORTSUM =SHORTSUM + Sday[ii];
>     {TOTAL ALL VALUES OF HIGHS BEING HIGHER THAN PRIOR HIGH}
>   COUNTSHORT = COUNTSHORT + IFF(Sday[ii]>0,1,0);
>     {COUNT NUMBER OF DAYS WITH HIGHS BEING HIGHER THAN PRIOR HIGH}
>   End;
> IF COUNTSHORT <> 0 THEN AVGHIGH = SHORTSUM / COUNTSHORT;
>     {GET AVERAGE OF HIGHS HIGHER THAN PRIOR HIGH}
> SSTOP = HIGH[1] + (MULTIPLESHORT * AVGHIGH[1]);
>     {CALCULATE STOP AT "X" TIMES AVGHIGH}
> SHORTSTOP = MINLIST(SSTOP, SSTOP[1], SSTOP[2], SSTOP[3], SSTOP[4],
> SSTOP[5]); {PREVENT STOP FROM RISING}
> IF CONDITION2 THEN PLOT1(SHORTSTOP, "STOP", ColourShort);
>     {SET PLOT}
>
>
>
>