OPEN-SOURCE SCRIPT
Telah dikemas kini [blackcat] L2 Ehlers DC using the Dual Differentiator

Level: 2
Background
John F. Ehlers introuced Measuring the Dominant Cycle using the Dual Differentiator in his "Cycle Analytics for Traders" chapter 14 on 2013.
Function
With Hilbert transformer, the first algorithm to compute the dominant cycle is called the dual differentiator. In this case, the phase angle is computed from the analytic signal as the arctangent of the ratio of the imaginary component to the real component. Further, the angular frequency is defined as the rate change of phase. We can use these facts to derive the cycle period.
Key Signal
DomCycle --> Dominant Cycle
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.
Remarks
The 59th 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 Measuring the Dominant Cycle using the Dual Differentiator in his "Cycle Analytics for Traders" chapter 14 on 2013.
Function
With Hilbert transformer, the first algorithm to compute the dominant cycle is called the dual differentiator. In this case, the phase angle is computed from the analytic signal as the arctangent of the ratio of the imaginary component to the real component. Further, the angular frequency is defined as the rate change of phase. We can use these facts to derive the cycle period.
Key Signal
DomCycle --> Dominant Cycle
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.
Remarks
The 59th 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.
Nota Keluaran
OVERVIEWThe [blackcat] L2 Ehlers DC using the Dual Differentiator indicator calculates the dominant cycle period in price action using Ehlers' Dual Differentiator method, providing traders with insights into market cycles.
FEATURES
• Calculates dominant cycle periods using advanced signal processing techniques
• Implements Ehlers' Dual Differentiator algorithm
• Includes highpass filtering and Super Smoother filtering
• Provides visual representation of cycle periods
• Adjustable LPPeriod parameter for customization
HOW TO USE
Add the indicator to your chart
Adjust the LPPeriod input parameter as needed: • Default value: 20 • Range: 1-100
Interpret the cycle periods shown on the chart
LIMITATIONS
• Results may vary depending on market conditions
• Requires sufficient historical data for accurate calculations
• Best suited for longer timeframes
NOTES
• The indicator uses two plotting styles to emphasize cycle periods
• Yellow columns show the base cycle periods
• Fuchsia line tracks the current cycle period
• Minimum cycle period is set to 8 bars
• Maximum cycle period is limited to 48 bars
Nota Keluaran
█ OVERVIEWThis indicator measures the dominant cycle period of price action in bars, using John Ehlers' Dual Differentiator discriminator. Cycle length is displayed as gradient-colored columns (short = orange, long = teal) with regime background highlighting, threshold lines and a live statistics table.
█ CONCEPTS
Price is first passed through a 48-bar highpass filter to remove spectral dilation, then through a 2-pole Super Smoother. The filtered signal is peak-normalized into an inphase component R, and quadrature Q is derived from its derivative. The Dual Differentiator then estimates the period:
Key principles:
• Cycle mode: short dominant cycles favor oscillators and mean-reversion tactics.
• Trend mode: a stretched dominant cycle signals trending conditions where oscillators whipsaw.
• The raw period is clamped (default 8-48 bars) and finally Super-Smoothed for readability.
█ HOW TO USE
1 — Add the indicator to any chart; it renders in its own pane below price.
2 — Read the column height: taller teal = longer cycles (trend), shorter orange = short cycles.
3 — Watch threshold crossovers (dashed lines) for regime shifts; use the table for context.
Input Parameters
• LP Period (default 20): Super Smoother cutoff; lower tracks shorter cycles.
• Min / Max Cycle Period (8 / 48): clamp range for the measured period.
• Short / Long Cycle Threshold (18 / 32): regime classification boundaries.
• Statistics Lookback (500 bars): window for mean, min/max and regime time shares.
• Status Table: show/hide, position and text size.
• Colors: gradient end colors for the shortest and longest cycles.
█ FEATURES
• Gradient-colored columns plus a step line with track-price marker.
• Regime background: orange tint in cycle mode, blue tint in trend mode.
• Status table: current period, regime, 1-bar change, bars in regime, cycle strength, and lookback statistics (min / max / mean, % time short / medium / long).
• Two alertconditions: Trend Mode Start and Cycle Mode Start.
• No repainting of historical bars; computed from close prices only.
█ IMPLEMENTATION NOTES
Pure Pine v6. Uses math.cos / math.sin / math.exp for the filters, ta.sma, ta.highest / ta.lowest for statistics, color.from_gradient for coloring, and a table refreshed on barstate.islast. The denominator sign in the code is intentional: deriving Q from the derivative of R flips its sign, so the negation restores a positive angular frequency. All stateful ta.* calls execute on every bar.
█ LIMITATIONS
• This is a market-research tool; it does not produce buy/sell signals.
• Cycle measurement gets noisy inside strong trends; clamping hides extreme values.
• Most informative on liquid markets and mid-range timeframes.
• Statistics need enough history within the chosen lookback window.
█ NOTES
• Based on John F. Ehlers' book "Cybernetic Analysis for Stocks and Futures".
• V2 of blackcat1402's L2 Dominant Cycle study, released under MPL 2.0.
═════════════════════════════════════════════════════════════════════════
For questions or feedback, use the comments section below.
Feel free to use and modify — attribution appreciated.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
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
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
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
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.