ที่อัปเดต:
[blackcat] L2 Ehlers Dual Differential Cycle Period Measurer

Level: 2
Background
John F. Ehlers introuced Dual Differential Cycle Period Measurer in his "Rocket Science for Traders" chapter 7. The In-phase and Quadrature components are computed with the Hilbert Transformer using procedures identical to those in the Dual Differentiator.
Function
blackcat L2 Ehlers Homodyne Discriminator Cycle Period Measurer is used to measure Dominant Cycle (DC). This is one of John Ehlers three major methods to measure DC. These components undergo a complex averaging and are smoothed in an EMA to avoid any undesired cross products in the multiplication step that follows. The period is solved directly from the smoothed Inphase and Quadrature components. The interim calculation for the denominator is performed as Value1 to ensure that the denominator will not have a zero value. The sign of Valuel is reversed relative to the theoretical equation because the differences are looking backward in time.
Key Signal
Smooth --> 4 bar WMA w/ 1 bar lag
Detrender --> The amplitude response of a minimum-length HT can be improved by adjusting the filter coefficients by
trial and error. HT does not allow DC component at zero frequency for transformation. So, Detrender is used to remove DC component/ trend component.
Q1 --> Quadrature phase signal
I1 --> In-phase signal
Period --> Dominant Cycle in bars
SmoothPeriod --> Period with complex averaging
Pros and Cons
100% John F. Ehlers definition translation of original work, even variable names are the same. This help readers who would like to use pine to read his book. If you had read his works, then you will be quite familiar with my code style.
Remarks
The 4th 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.
Background
John F. Ehlers introuced Dual Differential Cycle Period Measurer in his "Rocket Science for Traders" chapter 7. The In-phase and Quadrature components are computed with the Hilbert Transformer using procedures identical to those in the Dual Differentiator.
Function
blackcat L2 Ehlers Homodyne Discriminator Cycle Period Measurer is used to measure Dominant Cycle (DC). This is one of John Ehlers three major methods to measure DC. These components undergo a complex averaging and are smoothed in an EMA to avoid any undesired cross products in the multiplication step that follows. The period is solved directly from the smoothed Inphase and Quadrature components. The interim calculation for the denominator is performed as Value1 to ensure that the denominator will not have a zero value. The sign of Valuel is reversed relative to the theoretical equation because the differences are looking backward in time.
Key Signal
Smooth --> 4 bar WMA w/ 1 bar lag
Detrender --> The amplitude response of a minimum-length HT can be improved by adjusting the filter coefficients by
trial and error. HT does not allow DC component at zero frequency for transformation. So, Detrender is used to remove DC component/ trend component.
Q1 --> Quadrature phase signal
I1 --> In-phase signal
Period --> Dominant Cycle in bars
SmoothPeriod --> Period with complex averaging
Pros and Cons
100% John F. Ehlers definition translation of original work, even variable names are the same. This help readers who would like to use pine to read his book. If you had read his works, then you will be quite familiar with my code style.
Remarks
The 4th 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.
Release Note
OVERVIEWThe [blackcat] L2 Ehlers Dual Differential Cycle Period Measurer is a script designed to calculate and plot the Dual Differential Cycle Period using the Ehlers method. This indicator helps in identifying the dominant cycle period in price data, providing insights into market trends and potential turning points.
FEATURES
Source Input: Allows users to select the price source for the calculation.
Dual Differential Cycle Period Calculation: Implements the Ehlers method to determine the cycle period based on the selected price source.
Plotting Options: Displays the calculated cycle period using both column and stepline styles with customizable transparency.
HOW TO USE
Add the script to your TradingView chart.
Configure the Source input to select the desired price source (e.g., HL2).
Observe the plotted Dual Differential Cycle Period on the chart.
LIMITATIONS
The script may not perform optimally on very short timeframes due to the inherent smoothing and filtering involved.
Results are most effective on medium to long-term charts.
NOTES
The script uses a 6-bar lookback for initial calculations to ensure stability.
The cycle period is dynamically adjusted to stay within a reasonable range (6 to 50 bars).
Release Note
█ OVERVIEWEhlers Dual Differential Cycle Period Measurer is a research indicator that measures the dominant cycle period of any market in bars, revealing how fast the market is currently cycling. It renders the measured period as a regime-colored stepline with a full status dashboard, so short-cycle, medium-cycle, and long-cycle market states can be read at a glance.
█ CONCEPTS
The indicator applies John F. Ehlers' Dual Differential method, described in "Cybernetic Analysis for Stocks and Futures", to estimate the period of the dominant cycle contained in the price series. The measurement is adaptive: each new period estimate feeds back into the smoothing filters, so the detector continuously self-tunes to the market's current cycling speed.
Key principles:
• Adaptive measurement: the period estimate regulates its own smoothing filters, letting the detector track a changing market cadence
• Dual differential phasor: in-phase and quadrature components are advanced and differentiated to extract the cycle period
• Regime classification: the period is classified as short, medium, or long against user-defined thresholds
• Bounded output: the raw estimate is clamped and smoothed for a stable, readable line
█ HOW TO USE
1 — Add the indicator to any chart; it opens in its own pane below the price
2 — Read the stepline: higher values mean a slower market cycle, lower values a faster one
3 — Compare the line against the dotted threshold references to identify the current cycle regime
4 — Check the dashboard table in the top-right corner for the full status summary
Input Parameters
• Source: price series used for the measurement (default hl2)
• Period Floor (bars): lower clamp of the measured period (default 6)
• Period Cap (bars): upper clamp of the measured period (default 50)
• Short Cycle Threshold (bars): periods below this value are classified as short cycle (default 20)
• Long Cycle Threshold (bars): periods above this value are classified as long cycle (default 40)
• Show Columns: toggle the column-style rendering of the period (default true)
• Show Raw Period: toggle the unsmoothed raw period line (default false)
• Show Threshold Lines: toggle the dotted threshold reference lines (default true)
• Show Regime Background: toggle the regime background shading (default true)
• Show Dashboard: toggle the status table (default true)
• Stats Lookback (bars): lookback used for the Min/Max/Avg statistics in the dashboard (default 100)
• Warmup Bars: bars reserved for warmup before the measurement is considered stable (default 30)
• Enable Alerts: toggle the alert conditions (default true)
█ FEATURES
• Regime-colored stepline: aqua for short cycles, yellow for medium, orange for long, and red when the measurement saturates
• Optional column rendering and raw period line for visual cross-checking
• Dotted threshold reference lines at the short and long cycle thresholds
• Regime background shading with a distinct saturation warning state
• Status dashboard table: smoothed and raw period, regime, one-bar change, half period, Min/Max/Avg over the lookback, phasor magnitude, and measurement status
• Two alert conditions: cycle regime change and measurement saturation
█ SIGNALS
This is a research-type indicator: it produces no buy or sell signals.
Visual Elements
• DC Smooth stepline: the smoothed dominant cycle period in bars; the dotted track-price line marks the current value
• DC Columns: the same series rendered as columns for quick visual scanning
• DC Raw (optional): the period before the final smoothing stage
• Threshold lines: dotted references at the short and long cycle thresholds
• Background: aqua, yellow, or orange shading marks short, medium, or long regimes; red shading warns that the period is pinned at the floor or cap
• Dashboard: top-right table summarizing the current measurement state
█ IMPLEMENTATION NOTES
Open-source implementation of the Dual Differential cycle period measurement. The engine evaluates once per bar and returns the smoothed period, the raw period, and the phasor magnitude from a single pass. Dashboard statistics use ta.highest, ta.lowest, and ta.sma; the phasor magnitude uses math.sqrt. The estimate is bounded by configurable floor and cap clamps, and a small-differential guard prevents division by near-zero values:
█ LIMITATIONS
• Research and measurement tool only: it does not generate trade entries or exits
• The period estimate lags during rapid regime changes and needs a warmup period after loading
• When the measurement saturates at the floor or cap, the reading may be unreliable; the red background and the dashboard status flag this state
• Cycle period is a statistical property of past prices and does not predict future turning points with certainty
• Works on any timeframe; very low timeframes may produce noisier estimates
█ NOTES
• Based on the Dual Differential method described in John F. Ehlers, "Cybernetic Analysis for Stocks and Futures"
• License: Mozilla Public License 2.0; free to use and modify, attribution appreciated
• Feedback and improvement suggestions are welcome in the comments
═════════════════════════════════════════════════════════════════════════
For questions or feedback, use comments section below.
Feel free to use and modify — attribution appreciated.
Don't miss out! The first and most important thing to do is to join my Discord chat now! Click here to start your adventure: discord.com/invite/ZTGpQJq My new github for more pine development soon: github.com/wxt-coder
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
Don't miss out! The first and most important thing to do is to join my Discord chat now! Click here to start your adventure: discord.com/invite/ZTGpQJq My new github for more pine development soon: github.com/wxt-coder
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน