John Ehlers
[email protected]
StockSpotter.com
1
SPECTRAL DILATION And What To Do About It
The information provided is for informational purposes only. Trading is risky and is not for everyone. For a full disclosure statement, please go to: http://www.stockspotter.com/In/Legal.aspx
StockSpotter.com
OUTLINE
John Ehlers
[email protected]
• Theoretical Basis of Market Data Structure – Market Data is Fractal – Aliasing Noise Swamps Short Period Data
• Indicator Dynamics – Super Smoother Eliminates Aliasing Noise – Roofing Filter Mitigates Spectral Dilation – Improving Conventional Indicators
• Using Indicators to Predict Market Turning Points
2
StockSpotter.com
Drunkards Walk
John Ehlers
[email protected]
3
• Described in “MESA and Trading Market Cycles” – Drunk steps right or left with each step forward • Random Variable is position • Results in the famous Diffusion Equation • Describes the shape of a plume of smoke (or a trend)
– Drunk steps in the same or opposite direction as the last step with each step forward • Random Variable is momentum • Results in the famous Wave Equation • Describes a meandering river (or a cycle)
• The 2nd Order Partial Differential Equations are nearly identical • Results are that cycles and trends can coexist in a complex mixture
StockSpotter.com
Swerling Model
John Ehlers
[email protected]
• Peter Swerling statistically described radar echoes – Pulses were noisy over time – due to complex airplane shapes and changes in aspect from the fixed radar site. – Model described as pure noise with memory
• I have synthesized market data as noise with an EMA – Not bad for a simple model
4
StockSpotter.com
Hurst Exponent
John Ehlers
[email protected]
5
• The Hurst Exponent describes the randomness of a data series
“Hurst Exponent and Financial Market Predictability” By Bo Qian and Khaled Rasheed University of Georgia
StockSpotter.com
Logarithmic Spiral
John Ehlers
[email protected]
Fibonaccians use the Golden Spiral to show the relationship between cycle period and cycle amplitude
6
StockSpotter.com
•
Modeled Market Spectrum
John Ehlers
[email protected]
Signal Amplitude scales as 1/Fα Aliasing noise swamps signal power
• – –
•
Cycle periods less than 10 bars must be ignored Cycle components whose periods are less than 10 bars must be removed by filtering
Filtering components longer than 10 bars just reduces signal power –
Data contains systemic noise
7
Aliasing Noise
power
Spectral Dilation
Noise Intercepts Data
frequency
SMOOTHING FILTERS
StockSpotter.com
John Ehlers
[email protected]
8
The real reason to use filters is to remove aliasing noise Only the SuperSmoother Rejects Aliasing Noise 10 Bar EMA
10 Bar SuperSmoother Noise Removed
Only 13 dB Rejection
(10 Bar Period)
(10 Bar Period)
Longer Moving Averages Do Give More Rejection, But – Increase Indicator Lag – Attenuate the Real Signal – Not Just Aliasing Noise
StockSpotter.com
John Ehlers SuperSmoother Filter Code
[email protected]
SuperSmoother Filter © 2013 John F. Ehlers a1 = expvalue(-1.414*3.14159 / 10); b1 = 2*a1*Cosine(1.414*180 / 10); c2 = b1; c3 = -a1*a1; c1 = 1 - c2 - c3; Filt = c1*(Close + Close[1]) / 2 + c2*Filt[1] + c3*Filt[2]; Code Conversion Notes: 1) Filter is tuned to a 10 Bar Cycle (attenuates shorter cycle periods) 2) Arguments of Trig functions are in degrees 3) [N] means value of the variable “N” bars ago
9
StockSpotter.com
• •
Spectrum power models as 1/Fα Wave amplitude doubles for each doubling of cycle period – –
•
Modeled Market Spectrum
John Ehlers
[email protected]
Increases 6 dB per octave This is Spectral Dilation
Indicators must compensate for spectral dilation to get an accurate frequency response
10
Aliasing Noise
power
Spectral Dilation
Noise Intercepts Data
frequency
StockSpotter.com
HighPass Filter
John Ehlers
[email protected]
• HighPass Filters are oscillators (detrenders) because they attenuate low frequency components
A classical oscillator or ordinary HighPass filter does not produce a zero mean Because low frequency spectral dilation components are “leaking” through The one pole HighPass Filter response
11
StockSpotter.com
Roofing Filter
John Ehlers
[email protected]
• Comprised of a two pole HighPass Filter and a SuperSmoother
• The Roofing Filter guarantees only the desired frequency components will be passed for analysis • Establishes a true zero mean for swing signals
12
StockSpotter.com
Roofing Filter Code
John Ehlers
[email protected]
13
Roofing Filter © 2013 John F. Ehlers //Two Pole Highpass filter passes cyclic components whose periods are shorter than 48 bars alpha1 = (Cosine(.707*360 / 48) + Sine (.707*360 / 48) - 1) / Cosine(.707*360 / 48); HP = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) + 2*(1 - alpha1)*HP[1] - (1 - alpha1)*(1 - alpha1)*HP[2]; //Smooth with a Super Smoother Filter a1 = expvalue(-1.414*3.14159 / 10); b1 = 2*a1*Cosine(1.414*180 / 10); c2 = b1; c3 = -a1*a1; c1 = 1 - c2 - c3; Filt = c1*(HP + HP[1]) / 2 + c2*Filt[1] + c3*Filt[2];
Code Modification Notes: 1) HP Filter is tuned to a 48 Bar Cycle (attenuates longer cycle periods) 2) SuperSmoother is tuned to a 10 Bar Cycle (attenuates shorter cycle periods) 3) Arguments of Trig functions are in degrees 4) [N] means value of the variable “N” bars ago
StockSpotter.com
John Ehlers Impact of Spectral Dilation
[email protected] 14 On Traditional Indicators
• Spectral Dilation has distorted the interpretation of virtually all indicators • Roofing Filter removes Spectral Dilation distortion
Conventional Stochastic
Stochastic preceded by a Roofing Filter
StockSpotter.com
My Stochastic Code
John Ehlers
[email protected]
15
My Stochastic © 2013 John F. Ehlers //Highpass filter cyclic components whose periods are shorter than 48 bars alpha1 = (Cosine(.707*360 / 48) + Sine (.707*360 / 48) - 1) / Cosine(.707*360 / 48); HP = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close[1] + Close[2]) + 2*(1 - alpha1)*HP[1] - (1 - alpha1)*(1 - alpha1)*HP[2]; //Smooth with a Super Smoother Filter from equation 3-3 a1 = expvalue(-1.414*3.14159 / 10); b1 = 2*a1*Cosine(1.414*180 / 10); c2 = b1; c3 = -a1*a1; c1 = 1 - c2 - c3; Filt = c1*(HP + HP[1]) / 2 + c2*Filt[1] + c3*Filt[2]; HighestC = Filt; LowestC = Filt; For count = 0 to Length - 1 Begin If Filt[count] > HighestC then HighestC = Filt[count]; If Filt[count] < LowestC then LowestC = Filt[count]; End; Stoc = (Filt - LowestC) / (HighestC - LowestC); MyStochastic = c1*(Stoc + Stoc[1]) / 2 + c2*MyStochastic[1] + c3*MyStochastic[2];
Code Modification Notes: 1) HP Filter is tuned to a 48 Bar Cycle (attenuates longer cycle periods) 2) SuperSmoother is tuned to a 10 Bar Cycle (attenuates shorter cycle periods) 3) Arguments of Trig functions are in degrees 4) [N] means value of the variable “N” bars ago
StockSpotter.com
John Ehlers Conventional Wisdom
[email protected] 16 for Confirmation
• Buy when indicator crosses over 20% level • Sell Short when indicator crosses under 80% level
StockSpotter.com
Waiting For Confirmation
John Ehlers
[email protected]
• This equity curve of using (only) Conventional Wisdom rule using My Stochastic indicator on the last 10 years of S&P Futures data • Monthly cycle is 10 bars up – 10 bars down • Lag = 2 bars Roofing + 2 bars Stochastic + 1 bar after signal + 3 bars confirmation = 8 bars • 8 bars lag into a 10 bar move = consistent loss
17
StockSpotter.com
Prediction Anticipates the Cyclic Turning Point
John Ehlers
[email protected]
• Buy when indicator crosses under 20% level • Sell Short when indicator crosses over 80% level
18
StockSpotter.com
Anticipate the Turning Point
John Ehlers
[email protected]
• This equity curve of using (only) the Prediction rule using My Stochastic indicator on the last 10 years of S&P Futures data • Monthly cycle is 10 bars up – 10 bars down • Lag = 2 bars Roofing + 2 bars Stochastic + 1 bar after signal - 3 bars confirmation = 2 bars • 2 bars lag into a 10 bar move = consistent winner
19
StockSpotter.com
Swing Setup Analyzer
John Ehlers
[email protected]
20
StockSpotter.com
What You Have Learned
John Ehlers
[email protected]
• Spectral Dilation dominates market structure • Very short cycles are swamped by Aliasing Noise • Only a SuperSmoother can effectively remove aliasing noise • A Roofing filter additionally mitigates the effects of Spectral Dilation • Swing trading signals must anticipate the price turning points – A well constructed oscillator indicates the probability of reversion to the mean – In this sense an indicator can be predictive
21
StockSpotter.com
Contact Info
www.StockSpotter.com
John Ehlers
[email protected] (805) 927-3065
John Ehlers
[email protected]
22