Atualizado
[blackcat] L2 Ehlers Trendflex Cross

Level: 2
Background
John F. Ehlers introuced Trendflex indicator in Feb, 2020.
Function
In “Reflex: A New Zero-Lag Indicator” in Feb, 2020, John Ehlers introduces a new averaging indicator that he has designed with reducing lag in mind. According to the Dr. Ehlers, this new indicator can be used to generate signals in a more timely manner than other lagging calculations. The script displays the trendflex indicator discussed in the article. The reflex indicator synchronizes with the cycle component in the price data. Its companion, the trendflex oscillator, retains the trend component.
Key Signal
FastTF --> Ehlers Trendflex fast line
SlowTF --> Ehlers Trendflex 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.
Remarks
The 94th 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 Trendflex indicator in Feb, 2020.
Function
In “Reflex: A New Zero-Lag Indicator” in Feb, 2020, John Ehlers introduces a new averaging indicator that he has designed with reducing lag in mind. According to the Dr. Ehlers, this new indicator can be used to generate signals in a more timely manner than other lagging calculations. The script displays the trendflex indicator discussed in the article. The reflex indicator synchronizes with the cycle component in the price data. Its companion, the trendflex oscillator, retains the trend component.
Key Signal
FastTF --> Ehlers Trendflex fast line
SlowTF --> Ehlers Trendflex 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.
Remarks
The 94th 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.
Notas de Lançamento
OVERVIEWThis indicator implements the Ehlers Trendflex Cross strategy, providing trend analysis using two smoothed trendlines. It generates buy and sell signals based on crossovers between fast and slow Trendflex values.
FEATURES
• Dual-length Trendflex calculations
• Smoothed data processing for reduced noise
• Visual buy/sell signals with colored labels
• Automatic alerts for trading opportunities
• Customizable price inputs and lengths
HOW TO USE
Select the desired price input (default: hl2)
Configure FastLength (default: 20)
Configure SlowLength (default: 50)
Monitor crossover points for trading signals
Use alerts for automated notifications
PARAMETERS
• Price: The input price series for calculations
• FastLength: Period for faster trend identification
• SlowLength: Period for slower trend identification
LIMITATIONS
• Requires significant market movement for reliable signals
• May produce false signals during choppy markets
• Best used in conjunction with other indicators
NOTES
• Version 5 Pinescript implementation
• Based on John Ehlers' technical analysis methods
• Supports custom price inputs for flexibility
Notas de Lançamento
█ OVERVIEWblackcat L2 Ehlers Trendflex Cross V2 is an oscillator that runs two Ehlers Trendflex filters — a fast and a slow one — on the same price series and trades the crosses between them. Trendflex measures the average change of a smoothed filter output across its own lookback, normalized in standard deviations, so the fast and slow lines share one scale and their crosses mark real shifts in trend persistence rather than raw momentum spikes.
V2 keeps the original Ehlers math untouched and adds a cross-confirmation filter with an optional zero-line gate to cut whipsaw crosses, position-state governance with cooldown, ATR-based stop and target levels, four alert channels, and a state dashboard.
█ CONCEPTS
• Dual Trendflex cross: the fast line moving above the slow line is a long signal, moving below it is a short signal. Because both lines are normalized, a cross reads the same way on any symbol or timeframe.
• Signal Filter (default on): a cross must hold for N consecutive bars before any label or alert fires, so one-bar whipsaw crosses never trigger. Set N to 1 to recover the classic raw-cross behavior.
• Zero-Line Gate (optional): With Trend keeps longs only when the fast line is already above zero and shorts only below it; Counter Trend does the opposite, for oversold and overbought recoveries.
• Governance (optional): a position state machine (-1 / 0 / +1) gives exits priority over entries on the same bar, blocks duplicate same-direction signals, and enforces a minimum spacing between signals.
• Risk: each entry anchors an ATR-based stop and target, reported as numbers in the data window and dashboard — an oscillator pane has no price axis to draw them on.
█ INPUTS
• Signal: Price Source (hl2), Fast Length 20, Slow Length 50 — original defaults preserved.
• Signal Filter: Enable Cross Confirmation Filter (on), Cross Confirmation Bars (2; 1 = raw cross, up to 10), Zero-Line Mode (Off / With Trend / Counter Trend).
• Signal Governance: Enable State-Machine Governance (off), Cooldown Bars (3, 0 = off).
• Risk (ATR): Compute TP/SL Levels (on), ATR Length 14, Stop Loss 2.0 xATR, Take Profit 3.0 xATR.
• Visual: Signal Labels, Band Fill, Zero Line, Position State Background, Dashboard Table (all on).
█ SIGNALS
• BUY (green label): fast line confirmed above the slow line — potential long entry.
• SELL (red label): fast line confirmed below the slow line — potential short entry.
• XL / XS (orange X): governed exit from a long or short state when the opposite cross confirms.
• Band fill: yellow while fast is above slow, magenta while below; the gray line marks the normalization center at zero.
• Faint green / red background: governed long / short state.
• Dashboard: symbol and timeframe, position state, fast and slow values, spread, ATR, stop and target.
█ IMPLEMENTATION NOTES
Built on the published Ehlers Trendflex formulation — a SuperSmoother stage, a lookback difference, and normalization by an exponential mean square — driven by ta.crossover, ta.crossunder, ta.barssince and ta.atr. All ta.* calls run unconditionally on every bar. No request.security() is used, so nothing repaints across timeframes. Alerts evaluate on confirmed bars via alert.freq_once_per_bar_close.
█ LIMITATIONS
• With the filter on, signals confirm N bars after the cross: later entries in exchange for far fewer false triggers.
• Governance is off by default, so XL/XS markers, the state tint and the cooldown stay inactive until it is enabled.
• Stop and target levels are reference numbers from confirmed signals, not exchange orders.
• Trendflex needs its full lookback of history to settle; the first bars after loading are unreliable, and very short fast lengths make the cross noisy.
• As with any cross-based oscillator, signal quality degrades in flat, low-volatility ranges.
═════════════════════════════════════════════════════════════════════════
For questions or feedback, use the comments section below. Use and modify freely — 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
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
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
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.