John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

33
1 John Ehlers John Ehlers AfTA AfTA December 11, 2007 December 11, 2007 Left-Brained Concepts Left-Brained Concepts for Traders in for Traders in their Right Minds their Right Minds

Transcript of John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

Page 1: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

1

John EhlersJohn Ehlers

AfTA AfTA December 11, 2007December 11, 2007

Left-Brained Concepts Left-Brained Concepts for Traders in their Right Minds for Traders in their Right Minds

Page 2: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

2

John EhlersJohn Ehlers

John EhlersJohn Ehlers

• Pioneer of MESA studiesPioneer of MESA studies• FuturesTruth has ranked his S&P, Bond, and FuturesTruth has ranked his S&P, Bond, and

Currency trading systems #1Currency trading systems #1• Winner 27 Readers’ Choice Awards from Winner 27 Readers’ Choice Awards from

Stocks & Commodities magazineStocks & Commodities magazine• Author of MESA and Trading Market CyclesAuthor of MESA and Trading Market Cycles• Author of Rocket Science for TradersAuthor of Rocket Science for Traders• Author of Cybernetic Analysis for Stocks and Author of Cybernetic Analysis for Stocks and

FuturesFutures

Page 3: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

3

John EhlersJohn Ehlers

Hurst CoefficientHurst Coefficient

Page 4: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

4

John EhlersJohn Ehlers

Hurst CoefficientHurst Coefficient

• Named after H.E. Hurst, not J.M. HurstNamed after H.E. Hurst, not J.M. Hurst– Studied how high to make the Aswan dam on the NileStudied how high to make the Aswan dam on the Nile– Found the range did not widen as as in a coin tossFound the range did not widen as as in a coin toss– Rather:Rather:

• Hurst Coefficient is more estimated than computedHurst Coefficient is more estimated than computed– Rescaled range methodRescaled range method

• Log of R/S versus Log of lagLog of R/S versus Log of lag– Aggregated Variance MethodAggregated Variance Method

• N/m blocks of Size m plotted against Log(m)N/m blocks of Size m plotted against Log(m)– Differenced Variance MethodDifferenced Variance Method

• Used for long memoryUsed for long memory

• Aggregated Variance Method seems to work best for Aggregated Variance Method seems to work best for market datamarket data

N

73.2

kwhereN

Rk

Page 5: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

5

John EhlersJohn Ehlers

Aggregated Variance MethodAggregated Variance Method

• Start with the concept of the Fractal DimensionStart with the concept of the Fractal Dimension• Cover a generalized pattern of “N” objects of sizes “S”Cover a generalized pattern of “N” objects of sizes “S”

• Example 1Example 1– Line 10 meters long. Place boxes on line:Line 10 meters long. Place boxes on line:

• Ten 1 meter boxes, one hundred 0.1 meter boxesTen 1 meter boxes, one hundred 0.1 meter boxes• Therefore N1=10, S1= 1, N2=100, S2=0.1Therefore N1=10, S1= 1, N2=100, S2=0.1• D = 1.0D = 1.0

• Example 2Example 2– Square 10 Meters on a side. Place boxes in the squareSquare 10 Meters on a side. Place boxes in the square

• Now N1=100, N2=10000Now N1=100, N2=10000• D = 2.0D = 2.0

21

)1()2(

211

2

2

1

1

2

SSLog

NLogNLog

SSLogN

NLogD

S

S

N

ND

Page 6: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

6

John EhlersJohn Ehlers

Fractal Dimension of Market DataFractal Dimension of Market Data

• Since price samples are uniformly spaced, the box count is Since price samples are uniformly spaced, the box count is approximately the average slopeapproximately the average slope

• Box count is estimated as the price range divided by the intervalBox count is estimated as the price range divided by the interval• Divide the time into two segmentsDivide the time into two segments

– 0 to T and T to 2T0 to T and T to 2T– N1 is range over 1N1 is range over 1stst interval, N2 is range over 2 interval, N2 is range over 2ndnd interval, N3 is range interval, N3 is range

over the combined total intervalover the combined total interval

• Then:Then:)2(

)3()21(

Log

NLogNNLogD

Page 7: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

7

John EhlersJohn Ehlers

Hurst Coefficient DisplayHurst Coefficient Display

• Interpretations:Interpretations:– h = 0 means data are antipersistent (cyclic)h = 0 means data are antipersistent (cyclic)– h = 1 means data are persistent (trending)h = 1 means data are persistent (trending)– h = 0.5 means data are randomh = 0.5 means data are random

• Clearly, Hurst Coefficient depends on the Clearly, Hurst Coefficient depends on the selected lookback periodselected lookback period

• For each bar we will use a range of lookback For each bar we will use a range of lookback periods and colorize the value of the Hurst periods and colorize the value of the Hurst CoefficientCoefficient– Blue is cyclicBlue is cyclic– Green is trendingGreen is trending– Red is randomRed is random

5.01

2D

h

Page 8: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

8

John EhlersJohn Ehlers

Hurst EasyLanguage CodeHurst EasyLanguage CodeInputs:

Price((H+L)/2),Lookback(60);

Vars:I(0),N(0),count(0),N1(0),N2(0),N3(0),HH(0),LL(0),Dimen(0),Color1(0),Color2(0),Color3(0),PlotLen(0);

Arrays:H[190](0), H1[100](0), H2[100](0), H3[100](0), H4[100](0), HAvg[100](0);

For I = 1 to 50 BeginN = 2*I;N3 = (Highest(High, N) - Lowest(Low, N)) / N;HH = High;LL = Low;For count = 0 to N/2 - 1 begin

If High[count] > HH then HH = High[count];If Low[count] < LL then LL = Low[count];

End;N1 = (HH - LL)/(N / 2);HH = High[N/2];LL = Low[N/2];For count = N/2 to N - 1 begin

If High[count] > HH then HH = High[count];If Low[count] < LL then LL = Low[count];

End;N2 = (HH - LL)/(N / 2);

If N1 > 0 and N2 > 0 and N3 > 0 then Dimen = (Log(N1 + N2) - Log(N3)) / Log(2);H[N] = 2*(1 / Dimen - .5);H[N] = 1.25*(H[N] - .5) + .6;HAvg[N] = (H[N] + H1[N] + H2[N] + H3[N] + H4[N]) / 5;If HAvg[N] > 1 then HAvg[N] = 1;If HAvg[N] < 0 then HAvg[N] = 0;H4[N] = H3[N];H3[N] = H2[N];H2[N] = H1[N];H1[N] = H[N];

End;For I = 2 to 50 Begin

N = 2*I - 1;HAvg[N] = (HAvg[N - 1] + HAvg[N + 1]) / 2;

End;

//Plot the Rescale-range Statistic as a HeatmapPlotLen = Lookback;If Plotlen > 99 Then PlotLen = 99;For I = 8 to PlotLen Begin

//Convert RS to RGB Color for DisplayIf HAvg[I] >= .5 Then Begin

Color1 = 255*(2 - 2*HAvg[I]);Color2 = 255*(2*HAvg[I] - 1);Color3 = 0;

EndElse If HAvg[I] < .5 Then Begin

Color1 = 255*(2*HAvg[I]);Color2 = 0;Color3 = 255*(1 - 2*HAvg[I]);

End;If I = 4 Then Plot4(4, "S4", RGB(Color1, Color2, Color3),0,4);If I = 5 Then Plot5(5, "S5", RGB(Color1, Color2, Color3),0,4);If I = 6 Then Plot6(6, "S6", RGB(Color1, Color2, Color3),0,4);If I = 7 Then Plot7(7, "S7", RGB(Color1, Color2, Color3),0,4);If I = 8 Then Plot8(8, "S8", RGB(Color1, Color2, Color3),0,4);If I = 9 Then Plot9(9, "S9", RGB(Color1, Color2, Color3),0,4);If I = 10 Then Plot10(10, "S10", RGB(Color1, Color2, Color3),0,4);If I = 11 Then Plot11(11, "S11", RGB(Color1, Color2, Color3),0,4);If I = 12 Then Plot12(12, "S12", RGB(Color1, Color2, Color3),0,4);If I = 13 Then Plot13(13, "S13", RGB(Color1, Color2, Color3),0,4);If I = 14 Then Plot14(14, "S14", RGB(Color1, Color2, Color3),0,4);If I = 15 Then Plot15(15, "S15", RGB(Color1, Color2, Color3),0,4);If I = 16 Then Plot16(16, "S16", RGB(Color1, Color2, Color3),0,4);If I = 17 Then Plot17(17, "S17", RGB(Color1, Color2, Color3),0,4);If I = 18 Then Plot18(18, "S18", RGB(Color1, Color2, Color3),0,4);If I = 19 Then Plot19(19, "S19", RGB(Color1, Color2, Color3),0,4);If I = 20 Then Plot20(20, "S20", RGB(Color1, Color2, Color3),0,4);If I = 21 Then Plot21(21, "S21", RGB(Color1, Color2, Color3),0,4);If I = 22 Then Plot22(22, "S22", RGB(Color1, Color2, Color3),0,4);If I = 23 Then Plot23(23, "S23", RGB(Color1, Color2, Color3),0,4);If I = 24 Then Plot24(24, "S24", RGB(Color1, Color2, Color3),0,4);If I = 25 Then Plot25(25, "S25", RGB(Color1, Color2, Color3),0,4);If I = 26 Then Plot26(26, "S26", RGB(Color1, Color2, Color3),0,4);If I = 27 Then Plot27(27, "S27", RGB(Color1, Color2, Color3),0,4);If I = 28 Then Plot28(28, "S28", RGB(Color1, Color2, Color3),0,4);If I = 29 Then Plot29(29, "S29", RGB(Color1, Color2, Color3),0,4);If I = 30 Then Plot30(30, "S30", RGB(Color1, Color2, Color3),0,4);If I = 31 Then Plot31(31, "S31", RGB(Color1, Color2, Color3),0,4);If I = 32 Then Plot32(32, "S32", RGB(Color1, Color2, Color3),0,4);If I = 33 Then Plot33(33, "S33", RGB(Color1, Color2, Color3),0,4);If I = 34 Then Plot34(34, "S34", RGB(Color1, Color2, Color3),0,4);If I = 35 Then Plot35(35, "S35", RGB(Color1, Color2, Color3),0,4);If I = 36 Then Plot36(36, "S36", RGB(Color1, Color2, Color3),0,4);If I = 37 Then Plot37(37, "S37", RGB(Color1, Color2, Color3),0,4);If I = 38 Then Plot38(38, "S38", RGB(Color1, Color2, Color3),0,4);If I = 39 Then Plot39(39, "S39", RGB(Color1, Color2, Color3),0,4);If I = 40 Then Plot40(40, "S40", RGB(Color1, Color2, Color3),0,4);If I = 41 Then Plot41(41, "S41", RGB(Color1, Color2, Color3),0,4);If I = 42 Then Plot42(42, "S42", RGB(Color1, Color2, Color3),0,4);If I = 43 Then Plot43(43, "S43", RGB(Color1, Color2, Color3),0,4);If I = 44 Then Plot44(44, "S44", RGB(Color1, Color2, Color3),0,4);If I = 45 Then Plot45(45, "S45", RGB(Color1, Color2, Color3),0,4);If I = 46 Then Plot46(46, "S46", RGB(Color1, Color2, Color3),0,4);If I = 47 Then Plot47(47, "S47", RGB(Color1, Color2, Color3),0,4);If I = 48 Then Plot48(48, "S48", RGB(Color1, Color2, Color3),0,4);If I = 49 Then Plot49(49, "S49", RGB(Color1, Color2, Color3),0,4);If I = 50 Then Plot50(50, "S50", RGB(Color1, Color2, Color3),0,4);If I = 51 Then Plot51(51, "S41", RGB(Color1, Color2, Color3),0,4);If I = 52 Then Plot52(52, "S42", RGB(Color1, Color2, Color3),0,4);If I = 53 Then Plot53(53, "S43", RGB(Color1, Color2, Color3),0,4);If I = 54 Then Plot54(54, "S44", RGB(Color1, Color2, Color3),0,4);If I = 55 Then Plot55(55, "S45", RGB(Color1, Color2, Color3),0,4);If I = 56 Then Plot56(56, "S46", RGB(Color1, Color2, Color3),0,4);If I = 57 Then Plot57(57, "S47", RGB(Color1, Color2, Color3),0,4);If I = 58 Then Plot58(58, "S48", RGB(Color1, Color2, Color3),0,4);If I = 59 Then Plot59(59, "S49", RGB(Color1, Color2, Color3),0,4);If I = 60 Then Plot60(60, "S50", RGB(Color1, Color2, Color3),0,4);If I = 61 Then Plot61(61, "S41", RGB(Color1, Color2, Color3),0,4);If I = 62 Then Plot62(62, "S42", RGB(Color1, Color2, Color3),0,4);If I = 63 Then Plot63(63, "S43", RGB(Color1, Color2, Color3),0,4);If I = 64 Then Plot64(64, "S44", RGB(Color1, Color2, Color3),0,4);If I = 65 Then Plot65(65, "S45", RGB(Color1, Color2, Color3),0,4);If I = 66 Then Plot66(66, "S46", RGB(Color1, Color2, Color3),0,4);If I = 67 Then Plot67(67, "S47", RGB(Color1, Color2, Color3),0,4);If I = 68 Then Plot68(68, "S48", RGB(Color1, Color2, Color3),0,4);If I = 69 Then Plot69(69, "S49", RGB(Color1, Color2, Color3),0,4);If I = 70 Then Plot70(70, "S50", RGB(Color1, Color2, Color3),0,4);If I = 71 Then Plot71(71, "S41", RGB(Color1, Color2, Color3),0,4);If I = 72 Then Plot72(72, "S42", RGB(Color1, Color2, Color3),0,4);If I = 73 Then Plot73(73, "S43", RGB(Color1, Color2, Color3),0,4);If I = 74 Then Plot74(74, "S44", RGB(Color1, Color2, Color3),0,4);If I = 75 Then Plot75(75, "S45", RGB(Color1, Color2, Color3),0,4);If I = 76 Then Plot76(76, "S46", RGB(Color1, Color2, Color3),0,4);If I = 77 Then Plot77(77, "S47", RGB(Color1, Color2, Color3),0,4);If I = 78 Then Plot78(78, "S48", RGB(Color1, Color2, Color3),0,4);If I = 79 Then Plot79(79, "S49", RGB(Color1, Color2, Color3),0,4);If I = 80 Then Plot80(80, "S50", RGB(Color1, Color2, Color3),0,4);If I = 81 Then Plot81(81, "S41", RGB(Color1, Color2, Color3),0,4);If I = 82 Then Plot82(82, "S42", RGB(Color1, Color2, Color3),0,4);If I = 83 Then Plot83(83, "S43", RGB(Color1, Color2, Color3),0,4);If I = 84 Then Plot84(84, "S44", RGB(Color1, Color2, Color3),0,4);If I = 85 Then Plot85(85, "S45", RGB(Color1, Color2, Color3),0,4);If I = 86 Then Plot86(86, "S46", RGB(Color1, Color2, Color3),0,4);If I = 87 Then Plot87(87, "S47", RGB(Color1, Color2, Color3),0,4);If I = 88 Then Plot88(88, "S48", RGB(Color1, Color2, Color3),0,4);If I = 89 Then Plot89(89, "S49", RGB(Color1, Color2, Color3),0,4);If I = 90 Then Plot90(90, "S50", RGB(Color1, Color2, Color3),0,4);If I = 91 Then Plot91(91, "S41", RGB(Color1, Color2, Color3),0,4);If I = 92 Then Plot92(92, "S42", RGB(Color1, Color2, Color3),0,4);If I = 93 Then Plot93(93, "S43", RGB(Color1, Color2, Color3),0,4);If I = 94 Then Plot94(94, "S44", RGB(Color1, Color2, Color3),0,4);If I = 95 Then Plot95(95, "S45", RGB(Color1, Color2, Color3),0,4);If I = 96 Then Plot96(96, "S46", RGB(Color1, Color2, Color3),0,4);If I = 97 Then Plot97(97, "S47", RGB(Color1, Color2, Color3),0,4);If I = 98 Then Plot98(98, "S48", RGB(Color1, Color2, Color3),0,4);If I = 99 Then Plot99(99, "S49", RGB(Color1, Color2, Color3),0,4);

End;

Page 9: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

9

John EhlersJohn Ehlers

Hurst Coefficient DisplayHurst Coefficient Display

S&P Futures for 2007S&P Futures for 2007

Page 10: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

10

John EhlersJohn Ehlers

Probability of LosingProbability of Losing

Page 11: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

11

John EhlersJohn Ehlers

Statistics SoapboxStatistics Soapbox

• A good trading system has, say, 60% winnersA good trading system has, say, 60% winners– Therefore it has 40% losing tradesTherefore it has 40% losing trades– q = 0.4q = 0.4

• q = r + 2rq = r + 2r22 + 3r + 3r33 + 4r + 4r44 + 5r + 5r55 + ……. + …….• If q = 0.4 then r = 0.2349If q = 0.4 then r = 0.2349• Probability of getting 4 losers in a row is 4rProbability of getting 4 losers in a row is 4r44=0.0122=0.0122• If you trade 50 times per year, the probability of If you trade 50 times per year, the probability of

getting 4 losers in a row is 60.9% getting 4 losers in a row is 60.9% – That’s almost a promise it will happenThat’s almost a promise it will happen

• The message is that traders should not abandon a The message is that traders should not abandon a winning system in times of adversitywinning system in times of adversity

• Corollary: A trading system with high percentage Corollary: A trading system with high percentage winners is crucial for retaining customerswinners is crucial for retaining customers

Page 12: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

12

John EhlersJohn Ehlers

Bertrand’s Ballot TheoremBertrand’s Ballot Theorem

• If candidate A ultimately gets “a” votes and candidate B ultimately gets “b” votes If candidate A ultimately gets “a” votes and candidate B ultimately gets “b” votes (a>b), then the probability of Candidate A leading throughout the ballot counting (a>b), then the probability of Candidate A leading throughout the ballot counting process is (a-b) / (a+b)process is (a-b) / (a+b)

• In our case, let a = %*PF and b = (1-%). That is, if you win, you win by the Profit In our case, let a = %*PF and b = (1-%). That is, if you win, you win by the Profit Factor. If you lose, you lose 1.Factor. If you lose, you lose 1.

1

1%

01)1(*%

1)1(*%

1)1(*%

%)1(*%

%)1(*%

PF

OR

PF

nExpectatiopositiveFor

PF

PF

PF

PF

• PF must be greater than 2 (even then % must be certainty)PF must be greater than 2 (even then % must be certainty)

• Conclusion: It is almost a promise your account will go underwater some Conclusion: It is almost a promise your account will go underwater some time after you start trading!time after you start trading!

Page 13: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

13

John EhlersJohn Ehlers

Probability Density FunctionsProbability Density Functions

Page 14: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

14

John EhlersJohn Ehlers

Technical Analysis is Based on ProbabilityTechnical Analysis is Based on Probability

• ““The market is oversold because the The market is oversold because the Stochastic has been high, so when it crosses Stochastic has been high, so when it crosses through 80 then . . . . . .”through 80 then . . . . . .”

• ““When the head-and-shoulders pattern is When the head-and-shoulders pattern is complete then . . . . . .”complete then . . . . . .”

• ““When the market breaks above the upper When the market breaks above the upper channel then . . . . . .”channel then . . . . . .”

Let’s attack probability directly

Why fool around with rules?

Page 15: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

15

John EhlersJohn Ehlers

Normal (Gaussian) Probability Distribution Function (PDF) Normal (Gaussian) Probability Distribution Function (PDF) is Commonly Assumed for Market Datais Commonly Assumed for Market Data

0

0.05

0.1

0.15

0.2

0.25

0.3

-3

-2.8

-2.6

-2.4

-2.2 -2

-1.8

-1.6

-1.4

-1.2 -1

-0.8

-0.6

-0.4

-0.2 -0 0.2

0.4

0.6

0.8 1

1.2

1.4

1.6

1.8 2

2.2

2.4

2.6

2.8 3

Normal PDF Cumulative Normal PDF

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

-3

-2.8

-2.6

-2.4

-2.2 -2

-1.8

-1.6

-1.4

-1.2 -1

-0.8

-0.6

-0.4

-0.2 -0 0.2

0.4

0.6

0.8 1

1.2

1.4

1.6

1.8 2

2.2

2.4

2.6

2.8 3

0 = 50%+1 = 85%+2 = 98%+3 = 99.9%

2

2

2

2

x

eP

Normal PDF is attractive because it can be achieved using several random variables due to the central limit theorem

But is Normal the right PDF for market data?

Page 16: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

16

John EhlersJohn Ehlers

The PDF Depends on the Market WaveshapeThe PDF Depends on the Market Waveshape

-1.5

-1

-0.5

0

0.5

1

1.5

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

Square Wave

Sine Wave PDFSine Wave

Binary PDF of Square Wave

Page 17: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

17

John EhlersJohn Ehlers

How Do We Determine the Market PDF?How Do We Determine the Market PDF?

-1-0.9-0.8-0.7-0.6-0.5-0.4-0.3-0.2-0.1

00.10.20.30.40.50.60.70.80.9

1

Create the waveform bystringing beads on a horizontal wire frame

Rotate wire frame toenable beads to stack up

Height of the beadstacks is the PDFof the Waveform

Page 18: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

18

John EhlersJohn Ehlers

Channel Limited PDF Generator CodeChannel Limited PDF Generator Code

Inputs:Length(20);

Vars:HH(0),LL(0),J(0),I(0);

Arrays:Filt[2000](0),Bin[100](0);

HH = Close;LL = Close;For I = 0 to Length -1 Begin

If Close[I] > HH then HH = Close[I];If Close[I] < LL then LL = Close[I];

End;If HH <> LL Then Value1 = (Close - LL) / (HH - LL);Filt[CurrentBar] = (Value1 + 2*Value1[1] + Value1[2]) / 4;For I = 0 to 100 Begin

If Filt[J] >= I/100 and Filt[J] < (I + 1)/100 Then Bin[I] = Bin[I]+1;End;For I = 0 to 99 Begin

Print(File("c:\tsgrowth\pdf.csv"), I, ",", Bin[I]);End;Plot1(Filt[CurrentBar]);

Page 19: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

19

John EhlersJohn Ehlers

Channel PDF for Treasury BondsChannel PDF for Treasury Bonds

20 Bar Channel over 30 Years

40 Bar Channel over 30 Years

Page 20: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

20

John EhlersJohn Ehlers

Highpass Filter PDF Generator CodeHighpass Filter PDF Generator Code

Inputs:HPPeriod(40);

Vars:alpha(0), HP(0), HH(0), LL(0), Count(0), Psn(0), I(0);

Arrays:Bin[100](0);

alpha = (1 - Sine (360 / HPPeriod)) / Cosine(360 / HPPeriod);HP = .5*(1 + alpha)*(Close - Close[1]) + alpha*HP[1];IF CurrentBar = 1 THEN HP = 0;If CurrentBar > HPPeriod Then Begin

HH = HP;LL = HP;For Count = 0 to HPPeriod -1 Begin

If HP[Count] > HH Then HH = HP[Count];If HP[Count] < LL Then LL = HP[Count];

End;If HH <> LL Then Value1 = 100*(HP - LL) / (HH - LL);Psn = (Value1 + 2*Value1[1] + Value1[2]) / 4;

For I = 1 to 100 BeginIf Psn > I - 1 and Psn <= I Then Bin[I] = Bin[I] + 1;

End;Plot1(Psn);

End;If LastBarOnChart Then Begin

For I = 1 to 99 BeginPrint(File("C:\TSGrowth\PDF_HP.CSV"), I, ",", Bin[I]);

End;End;

Page 21: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

21

John EhlersJohn Ehlers

HP Filtered PDF for Treasury BondsHP Filtered PDF for Treasury Bonds

40 Bar Cutoff over 30 Years

Page 22: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

22

John EhlersJohn Ehlers

MyRSI PDF Generator CodeMyRSI PDF Generator Code

Inputs:Length(10);

Vars:CU(0), CD(0), I(0), MyRSI(0), Psn(0);

Arrays:Bin[100](0),PDF[100](0);

If CurrentBar > Length Then BeginCU = 0;CD = 0;For I = 0 to Length -1 Begin

If Close[I] - Close[I + 1] > 0 Then CU = CU + Close[I] - Close[I + 1];

If Close[I] - Close[I + 1] < 0 Then CD = CD + Close[I + 1] - Close[I];

End;If CU + CD <> 0 Then MyRSI = 50*((CU - CD) / (CU + CD) + 1);Psn = (MyRSI + 2*MyRSI[1] + MyRSI[2]) / 4;For I = 1 to 100 Begin

If Psn > I - 1 and Psn <= I Then Bin[I] = Bin[I] + 1;End;

End;If LastBarOnChart Then Begin

For I = 1 to 99 BeginPrint(File("C:\TSGrowth\PDF_RSI.CSV"), I, ",", PDF[I]);

End;End;

Page 23: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

23

John EhlersJohn Ehlers

MyRSI PDF for Treasury BondsMyRSI PDF for Treasury Bonds

10 Bar RSI over 30 Years

Page 24: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

24

John EhlersJohn Ehlers

PDF ConclusionsPDF Conclusions

• Probability Density Functions can vary widely, Probability Density Functions can vary widely, depending on the preprocessing useddepending on the preprocessing used

• A practical and useful trading system can be A practical and useful trading system can be developed by anticipating turning points developed by anticipating turning points knowing further excursions are low probability knowing further excursions are low probability eventsevents

Page 25: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

25

John EhlersJohn Ehlers

Fisher TransformFisher Transform

A PDF of virtually any processed data can be A PDF of virtually any processed data can be converted to a Normal PDF using the Fisher converted to a Normal PDF using the Fisher TransformTransform

Page 26: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

26

John EhlersJohn Ehlers

Fisher TransformFisher Transform

A Fisher Transform has no lag – it expands range near the endpointsA Fisher Transform has no lag – it expands range near the endpoints

x

xy

1

1ln*5.0

Page 27: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

27

John EhlersJohn Ehlers

Fisherized Channel PDF for Treasury BondsFisherized Channel PDF for Treasury Bonds

20 Bar Fisherized Channel over 30 Years

Original PDF

Page 28: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

28

John EhlersJohn Ehlers

Simple Trading SystemSimple Trading System

{>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Normalized Channel with Fisher Transform Trading System(c) 2007 John F. Ehlers

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}

Inputs:Length(8), UBound(.5), LBound(-.5);

Vars:HH(0), LL(0), FH(0), FL(0), Fisher(0), Count(0), Psn(0);

If CurrentBar > Length Then BeginHH = Close;LL = Close;For Count = 0 to Length - 1 Begin

If Close[Count] > HH Then HH = Close[Count];If Close[Count] < LL Then LL = Close[Count];

End;If HH <> LL Then Value1 = 2*((Close - LL) / (HH - LL) - .5);Psn = (Value1 + 2*Value1[1] + Value1[2]) / 4;If Psn > .999 Then Psn = .999;If Psn < -.999 Then Psn = -.999;Fisher = .5*Log((1 + Psn) / (1 - Psn));

End;

If Fisher Crosses Over UBound Then Sell Short Next Bar on Open;If Fisher Crosses Under LBound Then Buy Next Bar on Open;

Page 29: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

29

John EhlersJohn Ehlers

Trading System ResultsTrading System Results

• @SP.P for the life of the contract (from April 1982)@SP.P for the life of the contract (from April 1982)• 608 Trades (about once every two weeks)608 Trades (about once every two weeks)• 68.9% Profitable Trades68.9% Profitable Trades• Profit Factor = 1.75Profit Factor = 1.75

Page 30: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

30

John EhlersJohn Ehlers

Trading System Results (2)Trading System Results (2)

• @US.P for last 10 [email protected] for last 10 years• 196 Trades (about once every two and a half weeks)196 Trades (about once every two and a half weeks)• 63.8% Profitable Trades63.8% Profitable Trades• Profit Factor = 1.60Profit Factor = 1.60

Page 31: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

31

John EhlersJohn Ehlers

ConclusionsConclusions

• Hurst Coefficient can be used for a global view of Hurst Coefficient can be used for a global view of the datathe data

• Stick with a trading system through its adversityStick with a trading system through its adversity• Probability Density Functions of data can vary Probability Density Functions of data can vary

widely depending on preprocessingwidely depending on preprocessing• The Fisher Transform can produce Normal PDF-The Fisher Transform can produce Normal PDF-

shaped probability functions regardless of shaped probability functions regardless of preprocessingpreprocessing

• Simple but elegant trading systems can be Simple but elegant trading systems can be developed just from Probability Density Function developed just from Probability Density Function considerationsconsiderations

Page 32: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

32

John EhlersJohn Ehlers

ENGINEERS ARE AS

AS ANYONE

2

2

2

)(

2

1

x

e

Above All, RememberAbove All, Remember

Page 33: John Ehlers 1 AfTA December 11, 2007 Left-Brained Concepts for Traders in their Right Minds.

33

John EhlersJohn Ehlers

For More InformationFor More Information

• Trading sites coming in JanuaryTrading sites coming in January– www.eminiz.comwww.eminiz.com– www.indicez.comwww.indicez.com

• Meanwhile, try the indicator dashboard atMeanwhile, try the indicator dashboard at– www.isignals.com/previewwww.isignals.com/preview