
The Ehlers Three-Pole Butterworth Filter Crossover Trend Quantitative Trading Strategy is a technical analysis method based on signal processing theory, applying John Ehlers’ three-pole Butterworth filtering algorithm to financial market data. This strategy smooths price fluctuations through filtering, identifies potential market trends, and generates trading signals using crossover points between filter values and trigger values. Additionally, the strategy integrates divergence detection mechanisms to capture regular and hidden bullish and bearish market signals, improving the accuracy of trading decisions. The core advantage of this strategy lies in effectively reducing market noise, enhancing trend identification reliability, and controlling trading risk through precise entry and exit points.
The core of the Ehlers Three-Pole Butterworth Filter Crossover Trend Quantitative Trading Strategy lies in its unique mathematical model. The Butterworth filter is a low-pass filter widely used in signal processing, characterized by its maximally flat amplitude response in the passband. In financial markets, this feature allows it to effectively filter short-term price fluctuations while preserving long-term trend information.
The implementation of this strategy is based on the following steps:
Filter Calculation: The three-pole Butterworth filter values are calculated through the calculateButterworthFilter function. This function uses mathematical formulas to convert raw price data into smoothed filter values and corresponding trigger values. The filtering calculation involves complex mathematical operations, including exponential functions, trigonometric functions, and recursive calculations.
Signal Generation: The strategy generates trading signals primarily through two methods:
Trade Execution: Based on the generated signals, corresponding trading operations are executed:
In the code, the strategy uses the strategy.entry and strategy.close functions to execute trading operations and visualizes trading signal points on the chart through the plotshape function.
The Ehlers Three-Pole Butterworth Filter Crossover Trend Quantitative Trading Strategy offers several significant advantages:
Powerful Noise Filtering Capability: The three-pole Butterworth filter possesses excellent signal smoothing ability, effectively filtering short-term market fluctuations and false signals, making it easier for traders to identify genuine market trends. This efficient filtering is achieved through precisely calculated coefficients (coef1 to coef4) in the code.
Precise Trend Identification: The crossover between the filter and trigger lines provides clear signals of trend changes, allowing traders to capture key turning points in market trends in a timely manner. Through the ta.crossover and ta.crossunder functions, the strategy precisely identifies these critical crossover points.
Visual Intuitiveness: The strategy uses different colored lines and filled areas on the chart to visually display the relationship between filter values and trigger values, facilitating quick assessment of current market conditions. Yellow indicates bullish trends, while purple indicates bearish trends.
Flexibility: The strategy provides options for customizing price inputs and period parameters, allowing traders to adjust strategy parameters according to different market environments and personal preferences.
Complete Trading System: The strategy not only includes signal generation mechanisms but also integrates complete trading logic, including entry and exit rules, making it an independently usable trading system.
Signal Visualization: Through the plotshape function, the strategy marks buy and sell signal points on the chart, allowing traders to intuitively understand historical signal performance, facilitating strategy evaluation and optimization.
Despite the many advantages of the Ehlers Three-Pole Butterworth Filter Crossover Trend Quantitative Trading Strategy, there are still some potential risks:
Lag Risk: As a filter indicator, this strategy inevitably has some lag. Although the three-pole Butterworth filter has less lag compared to simple moving averages, in rapidly changing markets, signals may still appear later than ideal entry points. To reduce this risk, consider shortening the period parameter, but this may also lead to excessive signal sensitivity.
False Signal Risk: In oscillating markets or markets without clear trends, the strategy may produce numerous false signals, resulting in frequent trading and unnecessary transaction fee losses. This risk can be mitigated by adding additional filtering conditions or combining with other indicators for confirmation.
Parameter Sensitivity: Strategy performance is highly dependent on the choice of period parameters. Different market environments may require different parameter settings, and incorrect parameter choices may lead to poor strategy performance. It is recommended to optimize parameters for different market environments through historical backtesting.
Single Indicator Risk: Relying on a single indicator for trading decisions may lead to poor performance in certain specific market environments. It is recommended to use this strategy as part of a trading system, combining it with other indicators or methods for comprehensive judgment.
Systemic Risk: In extreme market conditions, such as severe volatility or liquidity drought, any technical indicator based on historical data may fail. It is recommended to set appropriate risk control measures, such as stop-loss orders and position size management.
Based on an in-depth analysis of the Ehlers Three-Pole Butterworth Filter Crossover Trend Quantitative Trading Strategy, here are several possible optimization directions:
Adaptive Parameter Design: The current strategy uses fixed period parameters. Consider implementing an adaptive parameter mechanism that automatically adjusts period parameters based on market volatility. For example, by calculating the Average True Range (ATR) of prices to dynamically adjust period parameters, using shorter periods in high-volatility markets and longer periods in low-volatility markets.
Multi-Period Confirmation: Introduce filter calculations across multiple time periods, requiring signal consistency confirmation across different time periods to reduce false signals. Code could be added as follows:
[butterLong, triggerLong] = calculateButterworthFilter(priceInput, periodInput * 2)
longConfirmation = butter > trigger and butterLong > triggerLong
Add Auxiliary Indicators: Integrate other technical indicators as signal filters, such as Relative Strength Index (RSI), Stochastic, or volume indicators, executing trades only when confirmed by auxiliary indicators.
Risk Management Enhancement: Add dynamic stop-loss and take-profit mechanisms to the strategy, automatically adjusting stop-loss distances based on market volatility. Additionally, implement position size calculations based on money management principles.
Optimize Divergence Detection: The current code mentions divergence detection but does not elaborate on its implementation. Improve the divergence detection algorithm, especially for identifying hidden divergences, to further enhance signal quality.
Market Environment Filtering: Add market environment recognition mechanisms to use different trading rules in different market environments. For example, use long-period trend indicators to determine whether the current market is trending or oscillating, and adjust the trading strategy accordingly.
Machine Learning Enhancement: Consider introducing machine learning methods, such as classification algorithms or reinforcement learning, to optimize parameter selection and signal generation processes, improving the adaptive capacity of the strategy.
The Ehlers Three-Pole Butterworth Filter Crossover Trend Quantitative Trading Strategy combines signal processing theory with technical analysis, providing a scientific and systematic method for market trend identification. Through advanced filtering algorithms, this strategy reduces market noise and captures key turning points in price trends, providing objective and quantifiable bases for trading decisions.
The core advantages of the strategy lie in its powerful noise filtering capability and precise trend identification function, making it excel in markets with clear trends. At the same time, by providing visualized trading signals and flexible parameter adjustment options, the strategy meets the personalized needs of different traders.
However, like all technical indicators, this strategy also faces challenges such as lag, false signals, and parameter sensitivity. By implementing optimization measures such as adaptive parameter design, multi-period confirmation, and auxiliary indicator integration, the robustness and adaptability of the strategy can be further enhanced.
Ultimately, the Ehlers Three-Pole Butterworth Filter Crossover Trend Quantitative Trading Strategy provides quantitative traders with a trading tool based on solid mathematical foundations. It can be used either as an independent trading system or as a component of more complex trading strategies, providing valuable reference information for trading decisions. Through continuous optimization and improvement, this strategy has the potential to achieve stable and sustainable trading performance in various market environments.
/*backtest
start: 2025-01-01 00:00:00
end: 2025-06-12 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Ehlers Three Pole Butterworth Filter Strategy", overlay=true)
// 输入参数
priceInput = input(hl2, title='Price')
periodInput = input(15, title='Period')
// Function to calculate Ehlers Three Pole Butterworth Filter
calculateButterworthFilter(price, period) =>
a1 = 0.00
b1 = 0.00
c1 = 0.00
coef1 = 0.00
coef2 = 0.00
coef3 = 0.00
coef4 = 0.00
butter = 0.00
trigger = 0.00
pi = 2 * math.asin(1)
a1 := math.exp(-3.14159 / period)
b1 := 2 * a1 * math.cos(1.738 * pi / period)
c1 := a1 * a1
coef2 := b1 + c1
coef3 := -(c1 + b1 * c1)
coef4 := c1 * c1
coef1 := (1 - b1 + c1) * (1 - c1) / 8
butter := coef1 * (price + 3 * nz(price[1]) + 3 * nz(price[2]) + nz(price[3])) + coef2 * nz(butter[1]) + coef3 * nz(butter[2]) + coef4 * nz(butter[3])
butter := bar_index < 4 ? price : butter
trigger := nz(butter[1])
[butter, trigger]
// Calculate filter values
[butter, trigger] = calculateButterworthFilter(priceInput, periodInput)
// 绘制滤波器线
plotButter = plot(butter, 'Butter', color=color.new(color.yellow, 0), linewidth=3)
plotTrigger = plot(trigger, 'Butter Lag', color=color.new(color.fuchsia, 0), linewidth=3)
fill(plotButter, plotTrigger, color=butter > trigger ? color.yellow : color.fuchsia, transp=40)
// 定义交易信号
longCondition = ta.crossover(butter, trigger)
exitLongCondition = ta.crossunder(butter, trigger)
shortCondition = ta.crossunder(butter, trigger)
exitShortCondition = ta.crossover(butter, trigger)
// 执行交易
if (longCondition)
strategy.entry("Buy", strategy.long)
if (exitLongCondition)
strategy.close("Buy")
if (shortCondition)
strategy.entry("Short", strategy.short)
if (exitShortCondition)
strategy.close("Short")
// 绘制交易信号
plotshape(longCondition, "Buy Signal", shape.triangleup, location.belowbar, color=color.green, size=size.small)
plotshape(exitLongCondition, "Exit Long Signal", shape.triangledown, location.abovebar, color=color.red, size=size.small)
plotshape(shortCondition, "Short Signal", shape.triangledown, location.abovebar, color=color.orange, size=size.small)
plotshape(exitShortCondition, "Exit Short Signal", shape.triangleup, location.belowbar, color=color.blue, size=size.small)