ZERO LAG DATA SMOOTHERS By John Ehlers

Similar documents
Predictive Indicators for Effective Trading Strategies By John Ehlers

John Ehlers systems.com TAOTN 2002

Lecture 17 z-transforms 2

Dr Ian R. Manchester

Series Resistance Compensation

Alex Benn. Math 7 - Outline First Semester ( ) (Numbers in parentheses are the relevant California Math Textbook Sections) Quarter 1 44 days

Microelectronic Circuits II. Ch 9 : Feedback

Andrea Zanchettin Automatic Control 1 AUTOMATIC CONTROL. Andrea M. Zanchettin, PhD Winter Semester, Linear control systems design Part 1

The exponentially weighted moving average applied to the control and monitoring of varying sample sizes

SIGMA-DELTA CONVERTER

My experience with the ANC-4 on 50 MHz Rev. 1

(i) Understanding of the characteristics of linear-phase finite impulse response (FIR) filters

Corso di DATI e SEGNALI BIOMEDICI 1. Carmelina Ruggiero Laboratorio MedInfo

Minimizing Input Filter Requirements In Military Power Supply Designs

Permutation group and determinants. (Dated: September 19, 2018)

Pole, zero and Bode plot

AC CURRENTS, VOLTAGES, FILTERS, and RESONANCE

NUMBER, NUMBER SYSTEMS, AND NUMBER RELATIONSHIPS. Kindergarten:

(i) Understanding of the characteristics of linear-phase finite impulse response (FIR) filters

Chapter 2 Shunt Active Power Filter

Advanced Digital Signal Processing Part 5: Digital Filters

Half bridge converter. DC balance with current signal injection

Application Note 7. Digital Audio FIR Crossover. Highlights Importing Transducer Response Data FIR Window Functions FIR Approximation Methods

Situations Involving Multiplication and Division with Products to 50

METHODS TO IMPROVE DYNAMIC RESPONSE OF POWER FACTOR PREREGULATORS: AN OVERVIEW

EE EXPERIMENT 8 CAPACITOR CURRENT-VOLTAGE RELATIONSHIP INTRODUCTION

Linear Systems. Claudia Feregrino-Uribe & Alicia Morales-Reyes Original material: Rene Cumplido. Autumn 2015, CCC-INAOE

Signal Processing. Naureen Ghani. December 9, 2017

Notes on OR Data Math Function

CHAPTER 6 INTRODUCTION TO SYSTEM IDENTIFICATION

Situations Involving Multiplication and Division with Products to 100

Chapter 7. Response of First-Order RL and RC Circuits

INTRODUCTION TO LOGARITHMS

Hundreds Grid. MathShop: Hundreds Grid

Andrea Zanchettin Automatic Control 1 AUTOMATIC CONTROL. Andrea M. Zanchettin, PhD Spring Semester, Linear control systems design

Application Note 106 IP2 Measurements of Wideband Amplifiers v1.0

Multiple : The product of a given whole number and another whole number. For example, some multiples of 3 are 3, 6, 9, and 12.

MESA 1. INTRODUCTION

Project 1. Notch filter Fig. 1: (Left) voice signal segment. (Right) segment corrupted by 700-Hz sinusoidal buzz.

Sect Linear Equations in Two Variables

On-Chip Implementation of Cascaded Integrated Comb filters (CIC) for DSP applications

Amplitude balancing for AVO analysis

ELEC-C5230 Digitaalisen signaalinkäsittelyn perusteet

Differential Amp DC Analysis by Robert L Rauck

Unit 6 Operational Amplifiers Chapter 5 (Sedra and Smith)

Studies on FIR Filter Pre-Emphasis for High-Speed Backplane Data Transmission

SECTION 6: ROOT LOCUS DESIGN

YGB #2: Aren t You a Square?

Digital Filtering: Realization

y(n)= Aa n u(n)+bu(n) b m sin(2πmt)= b 1 sin(2πt)+b 2 sin(4πt)+b 3 sin(6πt)+ m=1 x(t)= x = 2 ( b b b b

Applied Electronics II

On the Most Efficient M-Path Recursive Filter Structures and User Friendly Algorithms To Compute Their Coefficients

STANFORD UNIVERSITY. DEPARTMENT of ELECTRICAL ENGINEERING. EE 102B Spring 2013 Lab #05: Generating DTMF Signals

L_sson 9 Subtracting across zeros

EE Experiment 8 Bode Plots of Frequency Response

HARMONIC contamination, due to the increment of nonlinear

2.3 BUILDING THE PERFECT SQUARE

A Few Words about Pulse Width Modulation. The Rigol DG2041A, DG4000, and DG5000 Series of Arbitrary Waveform Generators support PWM.

A FREQUENCY SYNTHESIZER STRUCTURE BASED ON COINCIDENCE MIXER

Motomatic Servo Control

Design and responses of Butterworth and critically damped digital filters

A slope of a line is the ratio between the change in a vertical distance (rise) to the change in a horizontal

Signals and Systems Lecture 6: Fourier Applications

How Many Imputations are Really Needed? Some Practical Clarifications of Multiple Imputation Theory

Literature Review for Shunt Active Power Filters

Experiment 2 Effects of Filtering

Lab 3: RC Circuits. Construct circuit 2 in EveryCircuit. Set values for the capacitor and resistor to match those in figure 2 and set the frequency to

Synthesis Algorithms and Validation

Window Functions And Time-Domain Plotting In HFSS And SIwave

IDENTIFYING TREND MODES and CYCLE MODES

In this column, the Filter Wizard discusses a practical application of the time realignment filtering technique described in an earlier article.

The Air Bearing Throughput Edge By Kevin McCarthy, Chief Technology Officer

Solutions to Information Theory Exercise Problems 5 8

Signals and Systems Using MATLAB

Testing Power Sources for Stability

CHAPTER -2 NOTCH FILTER DESIGN TECHNIQUES

GREATER CLARK COUNTY SCHOOLS PACING GUIDE. Algebra I MATHEMATICS G R E A T E R C L A R K C O U N T Y S C H O O L S

The Filter Wizard issue 34: How linear phase filters can still cause phase distortion Kendall Castor-Perry

Position Control of DC Motor by Compensating Strategies

ELT Receiver Architectures and Signal Processing Fall Mandatory homework exercises

Communication Engineering Prof. Surendra Prasad Department of Electrical Engineering Indian Institute of Technology, Delhi

Lesson 1 6. Algebra: Variables and Expression. Students will be able to evaluate algebraic expressions.

Twenty-fourth Annual UNC Math Contest Final Round Solutions Jan 2016 [(3!)!] 4

Complex Digital Filters Using Isolated Poles and Zeroes

Notes on Noise Reduction

Week 4: Experiment 24. Using Nodal or Mesh Analysis to Solve AC Circuits with an addition of Equivalent Impedance

16.30 Learning Objectives and Practice Problems - - Lectures 16 through 20

Transmission Line Transient Overvoltages (Travelling Waves on Power Systems)

Current Rebuilding Concept Applied to Boost CCM for PF Correction

UNIVERSITY OF CALIFORNIA, SANTA BARBARA Department of Electrical and Computer Engineering. ECE 2A & 2B Laboratory Equipment Information

Loop Design. Chapter Introduction

CLOCK AND DATA RECOVERY (CDR) circuits incorporating

CHAPTER 9 FEEDBACK. NTUEE Electronics L.H. Lu 9-1

DC and AC Circuits. Objective. Theory. 1. Direct Current (DC) R-C Circuit

FIR/Convolution. Visulalizing the convolution sum. Convolution

Positive Feedback and Oscillators

ANALYTICAL SYNTHESIS OF PARAMETER-VARYING FILTER OF CONSTANT COMPONENT WITH APPLICATION TO SWITCHING SYSTEMS

[ á{tå TÄàt. Chapter Four. Time Domain Analysis of control system

Chapter 4 PID Design Example


Transcription:

ZERO LAG DATA SMOOTHERS By John Ehlers No causal filter can ever predict the future. As a matter of fact, the laws of nature demand that filters all must have lag. However, if we assume steady state conditions that is, no new disturbing events there are techniques we can use to reduce the lag of these filters to nearly zero. It turns out that such filters are useful for technical analysts to smooth data, and perhaps create some fast-acting indicators. This is possible because the steady state assumptions are almost satisfied in the short run. These techniques are not applicable to longer moving averages because steady state conditions do not continue over a long time span. There are superior techniques for creating longer term averages, such as nonlinear filters 1 or by removing undesired cycling components from a composite price waveform. 2 Engineers would describe the zero lag process as the placement of a zero in the filter transfer response such that the rate change of phase at zero frequency is zero. Traders, on the other hand, can easily understand the zero lag effect as a relationship between the lag of a moving average and momentum. In Figure 1 the solid line represents a steady state price movement and the dashed line represents a moving average of the price lagging by N bars. The lag is the horizontal span. An N bar momentum has the vertical span as shown. If we add the N bar momentum to the moving average we exactly recreate the original price movement. Thus, the goal of attaining a zero lag moving average can be realized with this approach. Figure 1. Steady State Lag Compensation Lag compensation can be applied to either FIR filters (like simple moving averages) or to IIR filters (like exponential moving averages). I will apply the lag compensation technique to both types of filters, but we must first review some filter theory. The data 1 John Ehlers, Rocket Science for Traders, John Wiley & Sons, Chapters 17 and 18 2 John Ehlers, MESA and Trading Market Cycles Second Edition, John Wiley & Sons, Chapter 9

we use in trading is sampled data. We only get the data once an hour, once a day, once a week, etc. One of the theories of sampled data is that the highest frequency we can analyze is at half the sampling frequency. If we are using daily bars, then the shortest period (that is, the highest frequency) is a 2 bar cycle. This highest frequency is called the Nyquist frequency. It is convenient to normalize all analysis to the Nyquist frequency. So, a 2 bar cycle has a normalized frequency of 1, a 4 bar cycle has a normalized frequency of 0.5, an 8 bar cycle has a normalized frequency of 0.2, and so on. The generalized equation relating the normalized frequency to cycle period is Freq = 2 / Period or, conversely, Period = 2 / Freq An exponential moving average works by taking a fraction of the current price and adding it to the quantity one minus the fraction times the previous filter output. The equation for an exponential moving average is Filt = *Price + (1- )*Filt[1] Where is the fraction and [1] means that function one bar ago Written this way, we are assured that the two coefficients sum to unity. The coefficient sum to unity is mandatory if the filter is to converge. For example, assume the price has been zero for a long time and then suddenly jumps to a value of 1. The filter output after the jump at the its input will be on the first sample. On the next sample the filter output will be + *(1- ). Eventually the filter output will converge to be near unity. The lag of an exponential moving average is Lag = 1/ - 1 3 Suppose = 0.2. In this case, lag is 4 bars. The equation for the usual exponential moving average (EMA) is Filt =.2*Price +.8*Filt[1] To obtain zero lag, we must add a 4 bar momentum to the input because the lag of the original EMA is 4 bars. The equation then becomes Filt =.2*(Price + (Price Price[4])) +.8*Filt[1] =.2*(2*Price Price[4]) +.8*Filt[1] Figure 2 shows the amplitude response of the original EMA as a function of frequency and Figure 3 shows its lag as a function of frequency. Note that the greatest lag occurs at zero frequency. Lag at frequencies where the output amplitude is attenuated is unimportant because small amplitudes make little contribution to the output. By contrast, Figure 4 shows the amplitude response of the IIR zero lag data smoother and Figure 5 shows its lag as a function of frequency. The zero frequency lag has been reduced to zero. The gain, or amplification of in-band frequencies is unavoidable. The gain can be reduced, but only at the expense of adding lag again. The gain contributes to overshoot at price turning points. We will show that this small increase in gain is tolerable in practical usage. 3 John Ehlers, MESA and Trading Market Cycles, John Wiley & Sons, Chapter 4

Figure 2. EMA Amplitude Response, = 0.2 Figure 3. EMA Lag Response, a = 0.2

Figure 4. Zero Lag IIR Filter Amplitude Response, = 0.2 Figure 5. Zero Lag IIR Filter Lag Response, = 0.2

My favorite FIR filter is Filt = (Price + 2*Price[1] + 3*Price[2] + 3*Price[3] + 2*Price[4] + Price[5])/12 It is my favorite because it exactly nulls out the 2 bar, 3 bar, and 4 bar cycle components that are present in the input price. The amplitude response of this filter is shown in Figure 6. An FIR filter is a linear phase filter and lag is defined as the rate change of phase as a function of frequency. This means that FIR filters have the same lag at all frequencies, and this lag is (N-1)/2 for an N element FIR filter. Since my favorite filter has 6 elements, its lag is 2.5 bars. Figure 6. Six Element FIR Filter Amplitude Response My favorite filter is already 6 bars long, and we prefer not to extend its length by another 2.5 bars when we compute the momentum. So, we will do the equivalent by multiplying a 1 bar momentum by 2.5. This is valid because we are assuming steady state conditions. We perform the calculations to compute the filter coefficients as shown in Table 1, which is equivalent to an Excel Spreadsheet. Column 1 list the coefficients of my favorite filter. Column 2 are these same coefficients delayed by 1 bar. Column 3 is the 1 bar momentum, obtained by subtracting Column 2 from Column 1 for rows that contain coefficients in Column 2. Column 4 is Column 3 multiplied by 2.5. The final filter coefficients are shown in Column 5 as the sum of the filter and the multiplied momentum (Columns 1 and 4). Therefore, the equation for the zero lag FIR filter is Filt = (Price + 4.5*Price[1] + 5.5*Price[2] + 3*Price[3] -.5*Price[4] 1.5*Price[5] 2.5*Price[6])/9.5 The filter is devided by 9.5 to normalize its output amplitude to the sum of the coefficients, providing zero gain at zero frequency.

Table 1. Computing Zero Lag FIR Filter Coefficients Filt Filt Lagged Momentum 2.5*Momentum Zero Lag Filt 1 1 2 1 1 2.5 4.5 3 2 1 2.5 5.5 3 3 0 0 3 2 3-1 -2.5 -.5 1 2-1 -2.5-1.5 1-1 -2.5-2.5 Several bad things happen to my favorite filter when we reduce its lag, as shown in Figure 7. First, the notch rejection of the 2 bar, 3 bar, and 4 bar cycles disappears. Second, the out of band attenuation is generally decreased. Third, there is a substantial increase in inband gain. This gain contributes to overshoots in the transient areas. But this is the price that must be paid to obtain zero lag. The lag response of the filter in Figure 8 shows that we attained our goal of zero lag at zero frequency. The large lags in the attenuation band of the filter are basically irrelevant because the amplitude of these components are reduced.

Figure 7. Zero Lag FIR Filter Amplitude Response Figure 8. Zero Lag FIR Filter Lag Response The real question of which zero lag filter is best for traders can only be answered in a comparison using real data.

Figure 9. Zero Lag IIR Filter is Preferred Because it gives less Transient Overshoot