Telah dikemas kini
[blackcat] L2 Ehlers Recursive Median Oscillator

Level: 2
Background
John F. Ehlers introuced Recursive Median Oscillator in Mar, 2018.
Function
In “Recursive Median Filters” in Mar, 2018, John Ehlers presented an approach for filtering out extreme price and volume data that could throw off typical averaging calculations. Dr. Ehlers’ line in digital signal processing extends to removing extreme spikes in financial data, but utilizing the median average value in the recursive filter calculations. By removing these extremities, the actual extremities that occur in the underlying data may be better determined. Ehlers goes on to present a novel oscillator using this technique, comparing its response to the well-known RSI. He notes that by being able to smooth the data with the least amount of lag, the recursive median oscillator may give the trader a better view of the bigger picture.
The recursive median filter (RMF) ignores the spiking-types of the price noise. RMF uses an exponential moving average of the five-period median of the source data to produce a smoothing of the signal while avoiding spikes. The recursive median oscillator (RMO) is an oscillator built along the same principles. The RMO has less lag and a faster response to the larger moves in the price data.
Key Signal
RMO --> Ehlers Recursive Median Oscillator fast line
RMO[2] --> Ehlers Recursive Median Oscillator 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 89th 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 Recursive Median Oscillator in Mar, 2018.
Function
In “Recursive Median Filters” in Mar, 2018, John Ehlers presented an approach for filtering out extreme price and volume data that could throw off typical averaging calculations. Dr. Ehlers’ line in digital signal processing extends to removing extreme spikes in financial data, but utilizing the median average value in the recursive filter calculations. By removing these extremities, the actual extremities that occur in the underlying data may be better determined. Ehlers goes on to present a novel oscillator using this technique, comparing its response to the well-known RSI. He notes that by being able to smooth the data with the least amount of lag, the recursive median oscillator may give the trader a better view of the bigger picture.
The recursive median filter (RMF) ignores the spiking-types of the price noise. RMF uses an exponential moving average of the five-period median of the source data to produce a smoothing of the signal while avoiding spikes. The recursive median oscillator (RMO) is an oscillator built along the same principles. The RMO has less lag and a faster response to the larger moves in the price data.
Key Signal
RMO --> Ehlers Recursive Median Oscillator fast line
RMO[2] --> Ehlers Recursive Median Oscillator 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 89th 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
OVERVIEW The Blackcat L2 Ehlers Recursive Median Oscillator is a technical indicator designed to identify potential buying and selling opportunities using recursive median calculations and high-pass/low-pass filtering techniques.FEATURES
• Calculates a recursive median oscillator based on Ehlers' method
• Generates BUY/SELL signals through crossover analysis
• Provides visual alerts and labels for trade signals
• Adjustable low-pass (LP) and high-pass (HP) periods
• Color-coded oscillator line for trend direction visualization
HOW TO USE
Add the indicator to your chart
Adjust the input parameters: • Price: Select the price source (default: HL2) • LPPeriod: Set the low-pass filter period (default: 12) • HPPeriod: Set the high-pass filter period (default: 30)
Monitor the oscillator line for directional changes
Watch for BUY/SELL labels for entry signals
TRADING SIGNALS
• BUY signal: Generated when oscillator crosses above previous value
• SELL signal: Generated when oscillator crosses below previous value
LIMITATIONS
• Like all technical indicators, this should be used in conjunction with other analysis tools
• Backtesting results may differ from live trading performance
• No guarantee of future trading success
PARAMETER EXPLANATION
• Price: The price data used for calculations (HL2 is the average of high and low prices)
• LPPeriod: Determines the smoothing effect of the low-pass filter
• HPPeriod: Controls the responsiveness of the high-pass filter
Nota Keluaran
█ OVERVIEWThe L2 Ehlers Recursive Median Oscillator V2 is a momentum indicator that filters price through a recursive median and a two-pole high-pass stage derived from John Ehlers' filter work. V2 keeps the classic oscillator intact and adds a complete trading layer: governed BUY/SELL entries, XL/XS exit marks, position background, ATR-scaled take-profit and stop-loss references, and four alert events.
█ CONCEPTS
The script is built on three layers:
• Recursive median stage: a super-smoothed low-pass (LPPeriod) applied to a 5-bar median of the selected price, suppressing spikes better than simple averaging
• Two-pole high-pass stage (HPPeriod): extracts the swing component from the smoothed median, producing the zero-centered RMO line
• Signal governance layer (new in V2): a position state machine with cooldown and same-bar exclusivity converts raw oscillator crosses into clean, non-repeating signals
When RMO crosses above its own value from two bars earlier, upward momentum is turning up; a cross below turns it down.
█ HOW TO USE
1 — Add the script to any chart; it loads in a separate pane below price
2 — Tune LPPeriod (default 12) for smoothing and HPPeriod (default 30) for swing sensitivity
3 — Read BUY/SELL labels as governed entry points, XL/XS orange crosses as exits, and the background tint as current position bias
4 — Check the dashboard (top right) for position, RMO value, slope, ATR, entry price and TP/SL levels
5 — Create alerts from Long Alert, Short Alert, Long Exit Alert or Short Exit Alert, or use the dynamic alert message
Input Parameters
• Price: source fed to the filter (default hl2)
• LPPeriod: low-pass period of the recursive median (default 12; avoid 4)
• HPPeriod: high-pass period of the oscillator stage (default 30)
• Same-bar Entry/Exit Exclusivity: blocks entry and exit on the same bar (default on)
• Cooldown Bars: minimum spacing between governed signals (default 3; 0 disables)
• Show TP/SL Levels, ATR Length, Stop Loss xATR, Take Profit xATR: ATR-scaled risk references (defaults on, 14, 2.0, 3.0)
• Show Signal Labels, Position Background, Dashboard: visual toggles (all default on)
█ FEATURES
• Original recursive median algorithm preserved unchanged from V1
• Position state machine removes whipsaw repeats and same-bar contradictions
• ATR-based TP/SL references adapt to each symbol's volatility
• Dynamic alert message includes direction and last price, fired once per confirmed bar close
• Data-window outputs for Position State, Stop Loss and Take Profit for screening tools
█ SIGNALS
Visual Elements
• Yellow RMO line: oscillator rising versus two bars ago; fuchsia: falling
• Green BUY label: governed long entry
• Red SELL label: governed short entry
• Orange XL / XS cross: exit of a long / short position on the opposite cross
• Green or red background tint: current long / short state
• Dashboard: Position, RMO, Slope, ATR, Entry, TP/SL at a glance
█ IMPLEMENTATION NOTES
• Uses ta.median, ta.crossover, ta.crossunder, ta.atr and label or table drawing objects; no request.security, so there is no higher-timeframe lookahead
• Signals are evaluated on confirmed oscillator values; the dynamic alert fires once per bar close
• TP/SL references sit at the entry close plus or minus an ATR multiple (informational levels, not orders)
█ LIMITATIONS
• Momentum-following oscillator: expect false swings in flat, ranging markets
• The state machine intentionally suppresses repeat crosses inside a position, so signal count is lower than raw V1 by design
• LPPeriod = 4 makes the filter denominator zero and disables output; any other value works
• Not a strategy: it does not place, manage or backtest orders
█ NOTES
• Based on the recursive median filter concept popularized by John F. Ehlers
• V1 by blackcat1402 under Mozilla Public License 2.0; V2 adds exits, governance, risk references, alerts and dashboard
• Charts below 15 minutes tend to be noisier; 1h and above are typically cleaner
═════════════════════════════════════════════════════════════════════════
For questions or feedback, use the 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
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.
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.