PureBytes Links
Trading Reference Links
|
Code seems correct for calculating what is described in the text.
normally, trailing stop is not based on current high, but highest high since
entry of trade, that is use: if high>higval then highval=high and replace
high with higval when calculating stops.
If you do not exit on current bar (which you do not since you plot your
trailing stop) I would recommend plotting trailing stop of previous bar
(Devstopx[1] in your code). This to give you a visual comparision with the
stop level that would have affected a trailiong stop system on the previous
bar.
> -----Original Message-----
> From: Barry Silberman [mailto:barry@xxxxxxxxxxxxxxxxxxxxx]
> Sent: Monday, January 10, 2000 8:35 PM
> To: omega-list@xxxxxxxxxx
> Subject: Help with Kase Dev-Stop
>
>
>
> I would appreciate it if someone could confirm and/ or
> correct the attached
> code I created for Cynthia Kase's Dev-stop. I attempted to
> follow the
> steps enumerated in Perry Kaufman's book "Trading Systems and
> Methods" (page
> 604), which are reproduced below: When I plot the values on
> a chart for
> IBM, for example, there are places where the first DEV-STOPS
> are above the
> price series in the chart. (Oct, 1999 - Jan, 2000). The
> scaling I used for
> ploting in the indicator on the chart was "Screen."
>
> I would appreciate any advice, and perhaps the finished
> product can be of
> use to others on the list.
>
> The word-for-word steps according to Perry Kaufman are:
>
> 1- Calculate the true range (TR) of the past 2 trading days using the
> highest high and the lowest low of the 2-day period.
> 2- Calculate the moving average ATR of TR (in step 1), using
> 30 periods for
> intraday charts and 20 periods for daily charts.
> 3- Calculate the standard deviation of the true ranges in
> step 1 using the
> same period as in step 2.
> 4- The stop-loss values are DDEV = ATR + (f * SDEV), where
> f=1, 2.06 to
> 2.25, and 3.20 to 3.50, and where the larger values of the
> pairs correct for
> skew and the larger numbers allow for larger risk.
> 5- The dev-stop for long positions is Trade High - DDEV; the
> dev-stop for
> short positions is Trade Low + DDEV.
>
>
> Shown below is the EL code I created. I'm sure it could have
> been much
> shorter, but making it go step by step helps me in these days
> of failing
> memory.
>
> ==============================================================
> ==============
> ============================
> {Kase's Standard Deviation Stop, called DEV-STOP. Coding based on
> description in Perry Kaufman's book "Trading Systems and
> Methods" -- pg
> 604}
>
> Inputs: fVal_1(1), fVal_2(2.1){values between 2.06 - 2.25},
> fVal_3(3.35){values between 3.20-3.50};
>
> Variables: HiVal(0), LoVal(0), TruerangeVal(0) ,
> AvgTrueRan(0), StandDev(0),
> DDev1(0), DDev2(0), DDev3(3), DevStop1(0),
> DevStop2(0), DevStop3(0), DevStop4(0), DevStop5(0),
> DevStop6(0);>
> HiVal = highest(high,2);
> {calculate
> highest high of past 2 trading days}
> LoVal = lowest(low,2);
> {calculate
> lowest low of past 2 trading days}
> TruerangeVal = hival - loval;
> {calculate
> true range of past 2 trading days}
> AvgTrueRan = Average(TruerangeVal, 20); {calculate
> moving average
> ATR of True range using 20 periods}
> StandDev = StdDev(TruerangeVal, 20);
> {Calculate std dev of
> true ranges using 20 periods}
>
> DDev1 = AvgTrueRan + (fVal_1 * StandDev);
> DDev2 = AvgTrueRan + (fVal_2 * StandDev);
> DDev3 = AvgTrueRan + (fVal_3 * StandDev);
>
> DevStop1 = high - DDev1; {Stop #1 for Long positions}
> DevStop2 = high - DDev2; {Stop #2 for Long positions}
> DevStop3 = high - DDev3; {Stop #3for Long positions}
>
> DevStop4 = low + DDev1; {Stop #1 for SHORT positions}
> DevStop5 = low + DDev2; {Stop #2 for SHORT positions}
> DevStop6 = low + DDev3; {Stop #3 for SHORT positions}
>
> Plot1(DevStop1," Dev-Stop-1");
> Plot2(DevStop2," Dev-Stop-2");
> Plot3(DevStop3," Dev-Stop-3");.
>
> ==============================================================
> ==============
> ====================
>
>
> Thank you for any help.
>
> Barry
>
>
>
|