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

Trailing Stop - Codes



PureBytes Links

Trading Reference Links

Thanks for all the responses to the question I posed on a trailing stop. 
They were very helpful.
Below is the code for the indicators I used in the chart I posted last week. 
I've also included the code author's name so if it is incorrect please 
advise.
Ian

TRADING THE TREND by Andrew Abraham
version 1
Name: Trading the Trend (code by Harvey Pearce)
Pds:= 21;
Mult:= 3;
TruRan:= Mov(ATR(1),Pds,W) * Mult;
HiLimit:= HHV(C,Pds) - TruRan;
LoLimit:= LLV(C,Pds) + TruRan;
If(C>HiLimit, HiLimit, LoLimit)

version 2
TTT-TREND TRAILING Ind - Andrew Abraham
{from TASC article SEP98 - TRADING THE TRENDS}(code by Ton Maas)

VOLAInd:=Mov(ATR(21),1,W)*3;

If(C>Ref(C,-21) AND C>VOLAInd,
HHV(H,21)-Ref(VOLAInd,-1),
Ref(VOLAInd,-1)+LLV(L,21))

VOLATILITY STOP (LONG)(Chande & Kroll) (code supplied by HHP)

Pds1:= Input("ATR Lookback?",2,100,10); Mult:= Input("ATR 
Multiplier?",1,20,3); Pds2:= Input("HHV Lookback?",2,100,20); PrelimStop:= 
HHV(H,Pds1) - ATR(Pds1)*Mult; ActualStop:= HHV(PrelimStop,Pds2); ActualStop

TRAILING STOP (code supplied by Yngvi Hardarson)
"....I would rather recommending trailing off the daily high for a long 
position. This however demands a little bigger ATR multiple i.e. something 
like:
For long: HHV(H - 2.5*ATR(5),10)
Furthermore it may be beneficial to dynamically adjust the number of 
lookback periods in the HHV() or the LLV() function.
Best regards, Yngvi Hardarson".

COUNT BACK LINE (from "Share Trading" by Daryl Guppy)
(code by Ken D,Bryan Stanton, Siobhan Channon) further info at Guppy site. 
There is also a CBLlo.

CBLhi:

HighDays := Input("Enter # days to cover last HIGH for CBL calc'n:", 3, 55, 
13);

If(HIGH < HHV(HIGH, HighDays), {then ...} PREV, {previous CBLhi, else...} 
If(Ref(L,-2) < Ref(L,-1) AND Ref(L,-2) < L AND Ref(L,-1) < L, {then ...} 
Ref(L,-2), {2nd day back low, else...} If((Ref(L,-3)< Ref(L,-2) AND 
Ref(L,-3) < Ref(L,-1) AND Ref(L,-3) < L) AND (Ref(L,-2)< L OR Ref(L,-1) < 
L), {then ... } Ref(L,-3), {3rd day back low, else...} If((Ref(L,-4)< 
Ref(L,-3) AND Ref(L,-4) < Ref(L,-2) AND Ref(L,-4) < Ref(L,-1) AND Ref(L,-4) 
< L) AND (Ref(L,-3)< L OR Ref(L,-2) < L OR Ref(L,-1) < L), {then... } 
Ref(L,-4), {4th day back low, else...} If((Ref(L,-5)< Ref(L,-4) AND 
Ref(L,-5) < Ref(L,-3) AND Ref(L,-5) < Ref(L,-2) AND Ref(L,-5) < Ref(L,-1) 
AND Ref(L,-5) < L) AND (Ref(L,-4)< L OR Ref(L,-3) < L OR Ref(L,-2) < L OR 
Ref(L,-1) < L), {then ...} Ref(L,-5), {5th day back low, else...} PREV )))))

To manually plot the Count Back Line in an uptrend -
>From the highest high bar (Bar 1), count back from the low of Bar 1 to the 
previous high bar(Bar 2). From the low of Bar 2 go back to the next bar with 
the highest high (Bar 3)and from the low of this bar plot the Count back 
Line to the right. If there is a close below this line then be on alert to 
exit. See chart attached.



______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

Attachment Converted: "f:\eudora\attach\Count Back Line1.gif"