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

[amibroker] Re: Elder's SafeZone Stop



PureBytes Links

Trading Reference Links

I have my own AFL of Safezone stop which I did last month that I'm 
happy to share.  It's a little less complex than the other posted 
version but it works fine for me!  It's the exact formula from 
Elder's book, Come Into My Trading Room.

*******************
/*SafeZone Stop*/
/*by Christopher Winn*/
/*September 1st, 2003*/

/*Programmed based on information presented in Dr. Alexander Elder's 
book "Come Into My Trading Room*/

/*This formula has been programmed with Parameter functionality.  
Both the Lookback period and the multiplier of the Average Downside 
Penetration can be modified as well as the colour of the Safezone 
Stop Line*/

GraphXSpace = 3;

/* OHLC chart */ 

Col = IIf ( Close > Ref (Close, -1), colorBrightGreen, colorRed);

Plot(Close,"", Col, styleBar + styleThick);


/*Moving average*/

EMAShort = Param ("EMA Short", 13, 1, 30, 1);

EMA1 = EMA (Close, EMAShort);

Plot (EMA1, "", colorYellow, styleLine);


/* Safezone Stop*/

DayLow = Low;

YesterdayLow = Ref (Low, -1);

DownsidePen = IIf ( (DayLow < YesterdayLow), (YesterdayLow - 
DayLow), 0);

Lookback = Param ("Lookback Period", 20, 2, 50, 1);

SumOfDownPen = Sum (DownSidePen, Lookback);

PenYorN = IIf ( (DayLow < YesterDayLow), 1, 0);

NumofDownPen = Sum (PenYorN, Lookback);

AvgDownPen = (SumofDownPen / NumofDownPen);

SafezoneCoeff = Param("Safezone Coefficient", 3, 1, 5, 0.1);

TodayStop = (YesterdayLow - (SafezoneCoeff * (Ref (AvgDownPen, -
1))));

Max1 = Max (TodayStop, Ref(TodayStop, -1));

Max2 = Max (Max1, Ref(TodayStop, -2));

ProtectedStop = Max (Max1, Max2);

Plot (ProtectedStop, "", ParamColor("Safe Zone Color", colorBlue), 
styleLine);

Daychange = 100*((Close / Ref (Close, -1))-1);

Title = Name() + " " + Date() + "   Reg Stop:  $" + WriteVal 
(TodayStop, 1.2) + ",   Protect Stop:  $" + WriteVal (ProtectedStop, 
1.2)+ "   Open  $" + WriteVal (Open, 1.2) + ",  High  $" + WriteVal 
(High, 1.2) + ",  Low  $" + WriteVal (Low, 1.2) + ",  Close  $" + 
WriteVal (Graph0, 1.2) + ",  Daychng  ($" + WriteVal ( (Close - Ref 
(Close, -1)), 2.2 ) + " , " + WriteVal (Daychange, 6.2) + "%)" 
+ "\n" + "Safe Zone Stop";

*********************

TTYL,
Chris



--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
wrote:
> Hello,
> 
> You have copied from HTML source where < is replaced by &lt;. 
> 
> Don't copy and paste, instead please use "Download formula file" 
link from:
> http://www.amibroker.com/library/detail.php?id=303
> 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "gonniejohnson" <gonniej@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Monday, October 20, 2003 9:47 PM
> Subject: [amibroker] Elder's SafeZone Stop
> 
> 
> > I just downloaded Elder's SafeZone Stop   by sloughbridge, added 
> > 2003-10-16 00:12:05 from the Ambroker On-Line_Library. i 
received 
> > the following error message:
> > "Line 38, Column 13:
> > Pd= Param("Period",9,2,50,1);  /*Lookback for DPs.  Elder: Do 
not go 
> > back past "the last important turning point."*/
> > DP= IIf(L&lt;
> > ------------^
> > Error 23.
> > Syntax error"
> >  (Quotes mine)
> > 
> > Can anyone help me to correct the error?  Thank You 
> > gonniej@xxxx
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at: 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > 
> > Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 
> > 
> > 
> >


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/