Butterworth (Dr.Koch)

Modified on 2016/06/10 07:11 by Eugene — Categorized as: Community Indicators

Butterworth: Indicator Documentation

Syntax

DataSeries Butterworth2( DataSeries Series, int Period) DataSeries Butterworth3( DataSeries Series, int Period)

Parameter Description

Series  A price series
Period  The critical period of the filter

Description

Butterworth IIR Filter
This filter can be used for smoothing. It rejects high frequencies (fast movements) better than an EMA and has lower lag. This filter is maximally smooth at zero frequency. Published by John F. Ehlers in "Rocket Science For Traders, Digital Signal Processing Applications"; original implementation by DrKoch, translation to WL5 by Eugene

Price movements (cycles) with this period are attenuated by 50 % (-3 dB)

Butterworth2 implements a two pole butterworth filter.
Butterworth3 implements a three pole butterworth filter.

From Ehlers Book:
"The first objective of using smoothers is to eliminate or reduce the undesired high-frequency components in th eprice data. Therefore these smoothers are called low-pass filters, and they all work by some form of averaging. Butterworth low-pass filtters con do this job, but nothing comes for free. A higher degree of filtering is necessarily accompanied by a larger amount of lag. We have come to see that is a fact of life."

The lag at low frequencies is:

Lag := N * P / pi^2

N - Number of Poles, 2 for butterworth2, 3 for butterworth3 P - critical period of the filter

Lag is higher for higher frequencies, being worse close to the cutoff frequency of the filter.

Special initialization of filter stages ensures proper working in scans with as few bars as possible.

Example

This example illustrates how to construct and plot the Butterworth filters.

public class IIRDemo : WealthScript { private StrategyParameter per2; private StrategyParameter per3; public IIRDemo() { per2 = CreateParameter("2pole period", 14, 2, 200, 2 ); per3 = CreateParameter("3pole period", 14, 3, 300, 3 ); } protected override void Execute() { Butterworth2 bw2 = Butterworth2.Series(Bars.Close, per2.ValueInt); Butterworth3 bw3 = Butterworth3.Series(Bars.Close, per3.ValueInt); PlotSeries( PricePane, bw2, Color.Green, LineStyle.Solid, 2 ); PlotSeries( PricePane, bw3, Color.Red, LineStyle.Solid, 2 ); } }