Quote from Trend Following:
<a href="http://www.michaelcovel.com/archives/001421.html">Film note</a>.
I don't think I would be good material for your flim. I wish you luck with your book although I believe it's value is more anecdotal than anything and I have Erma Bombeck and Readers Digest for that.
Secondly, I have done extensive backtesting and have written several algorithms using some of the methods Dennis instilled in his pupils and have had limited success as compared to the algos I use now. But if you would like to use it as an addendum to your current book or as part of the sequel here it is:
{
var ChannelUp, ChannelDn, LongExit, ShrtExit, FailsafeUp, FailsafeDn : integer;
var N, L1, S1, L2, S2, L3, S3, L4, S4, SE, LE, LS, SS, FU, FD, Account, tick: float;
var BrktProf : float;
var Bar, p, LeadBars, ATRParam, LstPsExBar : integer;
var cond20 : boolean;
{ Parameters input }
ChannelUp := 20 ;
ChannelDn := 20 ;
LongExit := 10 ;
ShrtExit := 10 ;
FailsafeUp := 55 ;
FailsafeDn := 55 ;
ATRParam := 20 ;
Account := 1000000 ; //This is the notional account
{ Cosmetics and general info }
HideVolume ;
PlotStops;
EnableNotes(True);
tick := GetTick ; //Tick Size in future table or 0
{ Indicators plotting }
PlotSeries( HighestSeries( #High, ChannelUp ), 0, #blue, #Thin );
PlotSeries( LowestSeries( #Low, ChannelDn ), 0, #fuchsia, #Thin );
PlotSeries( HighestSeries( #High, FailsafeUp ), 0, #green, #Dotted );
PlotSeries( LowestSeries( #Low, FailsafeDn ), 0, #green, #Dotted );
{ MAIN CYCLE }
LeadBars := Trunc(Max(FailsafeUp, FailsafeDn)); // Failsafe > Channel and Failsafe > Exit
for Bar := LeadBars to BarCount - 1 do
begin
SE := Highest( Bar, #High, ShrtExit) + tick ;
LE := Lowest( Bar, #Low, LongExit) - tick ;
N := ATR( Bar, ATRParam ); // N calculation
SetShareSize(Int( (Account * 0.01) / (N * GetPointValue))); // Unit
{ Entering the first position }
if PositionCount = 0 then begin
L1 := Highest( Bar, #High, ChannelUp) + tick ;
S1 := Lowest( Bar, #Low, ChannelDn) - tick ;
L2 := L1 + 0.5 * N ;
S2 := S1 - 0.5 * N ;
L3 := L1 + 1.0 * N ;
S3 := S1 - 1.0 * N ;
L4 := L1 + 1.5 * N ;
S4 := S1 - 1.5 * N ;
BuyAtStop( Bar + 1, L1, 'L1 ' + FormatFloat( '#0.00', L1));
ShortAtStop( Bar + 1, S1, 'S1 ' + FormatFloat( '#0.00', S1));
end; // of 'if PositionCount = 0 then'
{ Entering positions if not the first one }
if PositionCount > 0 then begin
if ActivePositionCount = 0 then begin
{ if cond20 is true, System 1 rules are triggered, otherwise
System 2 rules apply. Ref. Faith page 19; cond20 turns true
if last traded breakout was unprofitable. Faith rules state that
not traded breakouts should also be considered,
but this Script is currently limited to those actually traded. }
cond20 := false ;
BrktProf := 0 ;
LstPsExBar := PositionExitBar( PositionCount - 1 );
for p := 0 to PositionCount - 1 do begin
if PositionExitBar( p ) = LstPsExBar then
BrktProf := BrktProf + PositionProfit( p );
end ; // Sum up all position profits belonging to the last breakout
if BrktProf < 0 then
cond20 := true ;
if cond20 = true then begin
L1 := Highest( Bar, #High, ChannelUp) + tick ;
S1 := Lowest( Bar, #Low, ChannelDn) - tick ;
L2 := L1 + 0.5 * N ;
S2 := S1 - 0.5 * N ;
L3 := L1 + 1.0 * N ;
S3 := S1 - 1.0 * N ;
L4 := L1 + 1.5 * N ;
S4 := S1 - 1.5 * N ;
BuyAtStop( Bar + 1, L1, 'L1 '+ FormatFloat( '#0.00', L1));
ShortAtStop( Bar + 1, S1, 'S1 '+ FormatFloat( '#0.00', S1));
end // of cases where cond20 = true
else
begin
L1 := Highest( Bar, #High, FailsafeUp) + tick ;
S1 := Lowest( Bar, #Low, FailsafeDn) - tick ;
L2 := L1 + 0.5 * N ;
S2 := S1 - 0.5 * N ;
L3 := L1 + 1.0 * N ;
S3 := S1 - 1.0 * N ;
L4 := L1 + 1.5 * N ;
S4 := S1 - 1.5 * N ;
BuyAtStop( Bar + 1, L1, 'FU');
ShortAtStop( Bar + 1, S1, 'FD');
end; // of cases where cond20 = false
end; // of entering positions ActivePositionCount = 0
if ActivePositionCount = 1 then begin
LS := L1 - 2 * N ;
SS := S1 + 2 * N ;
BuyAtStop( Bar + 1, L2, 'L2 '+ FormatFloat( '#0.00', L2));
ShortAtStop (Bar + 1, S2, 'S2 '+ FormatFloat( '#0.00', S2));
end;
if ActivePositionCount = 2 then begin
LS := L2 - 2 * N ;
SS := S2 + 2 * N ;
BuyAtStop( Bar + 1, L3, 'L3 '+ FormatFloat( '#0.00', L3));
ShortAtStop (Bar + 1, S3, 'S3 '+ FormatFloat( '#0.00', S3));
end;
if ActivePositionCount = 3 then begin
LS := L3 - 2 * N ;
SS := S3 + 2 * N ;
BuyAtStop( Bar + 1, L4, 'L4 '+ FormatFloat( '#0.00', L4));
ShortAtStop (Bar + 1, S4, 'S4 '+ FormatFloat( '#0.00', S4));
end;
if ActivePositionCount = 4 then begin
LS := L4 - 2 * N ;
SS := S4 + 2 * N ;
end;
end; // of buying rules when PositionCount > 0
{ Check for position exit conditions }
for p := 0 to PositionCount -1 do begin
if PositionActive(p) then
if Positionlong(p) then SellAtStop( Bar + 1, LS, p, 'LongStop')
else CoverAtStop( Bar + 1, SS, p, 'ShortStop');
if PositionActive(p) then
if Positionlong(p) then SellAtStop( Bar + 1, LE, p, 'LongExit')
else CoverAtStop( Bar + 1, SE, p, 'ShortExit');
end; // of position exits
end; // OF THE MAIN CYCLE
}