Aggiornato

[blackcat] L2 Ehlers Fourier Series Strategy

4 974
Level: 2

Background

John F. Ehlers introuced Fourier Series Strategy in Jun, 2019.

Function

In “Fourier Series Model Of The Market” in Jun, 2019, John Ehlers introduces a Fourier series indicator designed to help traders identify cycles in the market. According to the author, the approach based on five principles outlined by J.M. Hurst in his 1970 book allows the determinization of a security’s primary cycle period and gives a faithful picture of market activity. It does so by applying a set of band-pass filters. His trading model’s rules are:

## 1. Buy next bar at market open when the FourierSeries(20) has reached a new 200-bar low and then turns up. This is an example of a “self-tuning” model, a concept we’ve been working with recently at Quantacula. Rather than establish an arbitrary oversold level, we use the historical data itself to look for an appropriate reversal level.
## 2. Sell at a limit price equal to the highest two-bar high. We’ve found that this exit works well to capture small gains in markets that are due for an upside move, while reducing exposure.


Key Signal

ROC --> Ehlers Fourier Series Strategy fast line
Trigger --> Ehlers Fourier Series Strategy slow line


Pros and Cons

100% John F. Ehlers definition translation, even variable names are the same. This help readers who would like to use pine to read his book.

NOTE: I did not figure out how to improve this indicator's performance because is not so good as my expectation. Whatever, I just keep it 100% as Ehlers original work to inspire you.

Remarks

The 92th script for Blackcat1402 John F. Ehlers Week publication.


Readme

In real life, I am a prolific inventor. I have successfully applied for more than 60 international and regional patents in the past 12 years. But in the past two years or so, I have tried to transfer my creativity to the development of trading strategies. Tradingview is the ideal platform for me. I am selecting and contributing some of the hundreds of scripts to publish in Tradingview community. Welcome everyone to interact with me to discuss these interesting pine scripts.

The scripts posted are categorized into 5 levels according to my efforts or manhours put into these works.

Level 1 : interesting script snippets or distinctive improvement from classic indicators or strategy. Level 1 scripts can usually appear in more complex indicators as a function module or element.

Level 2 : composite indicator/strategy. By selecting or combining several independent or dependent functions or sub indicators in proper way, the composite script exhibits a resonance phenomenon which can filter out noise or fake trading signal to enhance trading confidence level.

Level 3 : comprehensive indicator/strategy. They are simple trading systems based on my strategies. They are commonly containing several or all of entry signal, close signal, stop loss, take profit, re-entry, risk management, and position sizing techniques. Even some interesting fundamental and mass psychological aspects are incorporated.

Level 4 : script snippets or functions that do not disclose source code. Interesting element that can reveal market laws and work as raw material for indicators and strategies. If you find Level 1~2 scripts are helpful, Level 4 is a private version that took me far more efforts to develop.

Level 5 : indicator/strategy that do not disclose source code. private version of Level 3 script with my accumulated script processing skills or a large number of custom functions. I had a private function library built in past two years. Level 5 scripts use many of them to achieve private trading strategy.
Note di rilascio
OVERVIEW This script implements Ehlers Fourier Series Strategy, a technical analysis tool designed to identify potential buy and sell signals using harmonic wave analysis.
FEATURES
• Three harmonic band-pass filters (fundamental, second, and third harmonics)
• Real-time ROC (Rate of Change) and trigger line calculations
• Visual alerts with colored fills and labels
• Customizable parameters for price source, fundamental period, and bandwidth

HOW TO USE

Select the desired price source (default: HL2)
Adjust the fundamental period (default: 20)
Modify the bandwidth parameter (default: 0.1)
Monitor the ROC and trigger lines for crossovers
Use labels for visual confirmation of trading signals
PARAMETERS
• Price: Source price for analysis (HL2 by default)
• Fundamental: Period length for harmonic calculations (20 by default)
• Bandwidth: Controls filter sharpness (0.1 by default)

LIMITATIONS
• Requires minimum bars for accurate calculations
• Performance may vary in trending vs ranging markets
• Historical data availability affects harmonic accuracy
Note di rilascio
█ OVERVIEW

This indicator isolates the dominant cycle inside price and trades the rate of change of that reconstructed wave against an adaptive trigger line. Beyond the classic crossover logic it adds a full trading layer: state governed two-sided signals, ATR stop and target management, an optional higher timeframe gate, re-entry logic, a status dashboard and eight alert channels.

█ CONCEPTS

• Cycle isolation — three band-pass filters track the fundamental period plus its second and third harmonics, while quadrature channels measure the power of each.
• Power weighting — the harmonics are recombined with power-ratio weights, which preserves the shape of the market wave and suppresses noise.
• Adaptive trigger — the trigger line is a smoothed feedback of the oscillator, so the threshold moves with cycle energy.
• Signal governance — a position state machine keeps one state change per bar, blocks same-bar entry / exit conflicts and spaces signals out.
• Volatility aware risk — stop and target are set in ATR multiples, so risk scales with the instrument.

█ HOW TO USE

1 — Add the indicator to any symbol; it runs in its own pane.
2 — Set Fundamental to the cycle length in bars, default 20, and keep Bandwidth near 0.1.
3 — Green E marks a long opportunity and red S a short one; orange crosses are signal exits, maroon crosses are stop or target hits.
4 — The dashboard reports position, entry, live stop, target, ATR, gate state and remaining cooldown.

Input parameters
• Price — filter source, default hl2.
• Fundamental — cycle length, 4 to 200, default 20.
• Bandwidth — filter width, 0.01 to 0.9, default 0.1.
• Trigger Offset / Smoothing — trigger constant and feedback, defaults 0.05 and 0.9.
• Enable Long / Short Signals — supports one-sided markets.
• Same-bar Exclusivity, Cooldown Bars — arbitration and spacing; cooldown 0 disables it.
• Exit on Reverse Signal / Zero-Line Cross — two independent exit mechanisms.
• ATR Stop / Take-Profit, ATR Length, Stop xATR, Target xATR — defaults 2.0 and 3.0 times a 14 period ATR.
• Trailing Stop (Chandelier) with its own xATR — ratchets the stop behind the extreme since entry.
• HTF Direction Gate, HTF Timeframe, HTF EMA Length — suppresses counter-trend entries; off by default.
• Re-entry RL/RS, Anchor Window, Breakout Source — re-arms after an exit; off by default.
• Show Signal Labels / Background / Dashboard / Zero Line — visual switches.

█ FEATURES

• Two-sided, state aware signals with no duplicate entries and no same-bar contradictions.
• ATR stop, target and optional chandelier trailing stop.
• Optional higher timeframe gate on closed HTF bars, and optional re-entry anchored on the exit bar extreme.
• Eight alertcondition channels plus dynamic alerts, always once per bar close.

█ SIGNALS

• E — long entry, green label under the oscillator.
• S — short entry, red label above the oscillator.
• XL / XS — signal exit of a long or short position, orange cross.
• L-X / S-X — stop or target hit, maroon cross.
• E+RL / S+RS — entry generated by the re-entry logic.
• Background — light green while long, light red while short.
• Fill — yellow when the oscillator is above its trigger, fuchsia below.

█ IMPLEMENTATION NOTES

Open source under MPL 2.0. The band-pass and quadrature structure follows the Fourier work of John Ehlers; the trading layer uses ta.crossover, ta.crossunder, ta.atr, ta.highest and ta.lowest. The HTF gate reads closed HTF bars only, so it does not repaint, and every signal is final at bar close.

█ LIMITATIONS

• Cycle tools need a real cycle: violent trends and dead flat ranges both degrade signal quality.
• Cooldown and exclusivity lower the signal count — fewer but cleaner events than raw crossings.
• Stop and target are price based while the pane shows an oscillator; read them in the dashboard or data window.
• Decision support, not a stand-alone system.

█ NOTES

• Cycle theory and band-pass design by John F. Ehlers.
• Original script by blackcat1402; the core algorithm is unchanged and everything added is switchable.

═════════════════════════════════════════════════════════════════════════
For questions or feedback, use the comments section below.
Feel free to use and modify — attribution appreciated.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.