WiseTrader Toolbox

EndPointFFT

Background

The End Point Fast Fourier Transform (EPFFT) is a noise-filtered FFT rebuilt so it can actually be traded in real time. At each bar it transforms a trailing window of price, strips out the weak frequencies as noise, and keeps a single value — the end point. Stringing those end points together gives a smooth curve whose trend and, especially, whose turning points are what you watch. Because each value is locked in once and never revised in hindsight, the curve is honest about what you would actually have seen as each bar formed.

It comes from the published work of Dennis Meyers (his End Point Fast Fourier Transform articles in Stocks & Commodities). Keeping every surviving frequency, rather than just the single dominant cycle, makes it a more robust noise filter than a one-cycle method.

The FFT illusion

Why not just run an FFT across the whole chart? Because it will lie to you about the past. If you fit a noise-filtered FFT over an entire history, the curve hugs every top and bottom beautifully and can even seem to roll over just before a big decline, as if it predicted it. But that curve was drawn already knowing where the tops and bottoms were — the FFT's maths force a glove-tight fit to the data it is given. Re-draw it as it would have looked on the day of the top, using only the data available up to that day, and the apparent foresight evaporates: it points straight up into the drop. The smooth, prescient-looking whole-history FFT is hindsight, not prediction.

How the indicator works

To get an honest curve, the indicator walks forward one bar at a time. At each bar it noise-filters the FFT of the trailing window but keeps only the last point — the one value it could legitimately have known at that moment. Joining those end points reproduces what you would really have seen live. The honest cost is lag: instead of leading the turns, the EPFFT follows them by anywhere from zero to a few bars.

Each bar's value is built like this: take the natural log of the window (so a strong exponential trend does not dominate), remove its average level and straight-line trend, FFT it, zero out every frequency weaker than your Threshold times the strongest one, invert the transform and undo the log, then accumulate the change at the end point into a running curve. That running-sum construction keeps the curve smooth as the window slides forward and the raw numbers jitter.

Included formula

The toolbox ships a ready-made End Point FFT indicator, so you can see the curve without writing any code. In AmiBroker open the Charts window, expand the WiseTraderToolbox group and drag End Point FFT onto a chart; it plots the filtered curve, with the window length and noise threshold set from its parameters.

The band-breakout trading system described below is not part of that chart — the code here shows how to add it yourself.

The exported function

At the heart of the indicator is a single exported AFL function you can call directly. The rest of this page shows how to plot it and build a system around it.

EndPointFFT(DataArray, Periods, Threshold)
ParameterDescription
DataArray The data array the End Point FFT is performed on. It must not contain empty/null values at the left edge of the data, and the data must contain at least Periods bars.
Periods The length of the FFT window — the maximum number of bars each transform looks back over. It must be an even number of at least 8.
Threshold The noise-filter level, a value between 0 and 1. Any frequency whose amplitude is below Threshold times the largest amplitude is treated as noise and removed. A higher threshold filters more aggressively, leaving a smoother curve built from fewer cycles.

Returns a per-bar array holding the end-point FFT curve.

Plotting the curve

// 64-bar FFT window, drop any cycle weaker than 20% of the strongest.
signal = EndPointFFT( Close, 64, 0.2 );
Plot( signal, "End Point FFT", colorBlue );
Tip

Raise Threshold for a cleaner, smoother curve that reacts only to the strongest cycles; lower it to let more detail through. Focus on the curve's turning points — they are the most reliable feature of the EPFFT.

The trading system

Meyers traded the EPFFT curve exactly the way he traded the Goertzel curve: a stop-and-reverse band breakout that ignores the curve's small wiggles. You stay in the market and flip side only on a decisive turn — go long once the curve has rallied a set amount above the lowest point it reached while you were short, and go short once it has dropped a set amount below the highest point it reached while you were long. The runnable system on the Goertzel page drops straight onto this curve — just swap the Goertzel(…) call for EndPointFFT(…):

curve = EndPointFFT( Close, 64, 0.2 );   // then apply the same band-breakout rules

As with Goertzel, his intraday version also closed positions before the session ended and ignored the first hour of trading, and the two band sizes were fitted with walk-forward optimisation — tuned on one block of history and then traded on the untouched block that follows.

Warning

Periods must be even and at least 8, and Threshold must be greater than 0 and no more than 1, or the indicator returns an empty result. Because the window is log-transformed, feed it positive prices. And like every walk-forward method here, the band sizes can be curve-fitted to look great in-sample while meaning nothing out-of-sample — validate on data you did not optimise on, and remember the most recent curve values update as new bars arrive.

Note

The plain whole-history FFT and this end-point version are not the same tool: the first is a hindsight curve-fit, the second is what you could trade. See Digital Signal Processing for where the EPFFT sits among the other tools, and Goertzel for a related approach that targets specific cycle lengths instead of the whole spectrum.