█ Overview
This script implements a Synthetic Oscillator as presented by John F. Ehlers in the April 2026 TASC Traders' Tips article "Avoiding Whipsaw Trades". The indicator aims to provide a smooth, low-lag oscillator for timely trading signals by dynamically mapping a sine wave to price data.
█ CONCEPTS
"Whipsaw" trades are a common issue in algorithmic trading. They occur when the market quickly moves against a position, causing the trader/trading system to reverse their position at a loss, and then the market reverses again and continues in the original direction. Such trades occur because the trading system is attempting to react quickly to market moves instead of focusing on broader market cycles.
A typical solution for reducing whipsaw trades is to apply linear filters to smooth the data and emphasize specific cycles. However, linear filters cannot have both a smooth response and a low computational lag. Therefore, strategy designs utilizing linear filters require a tradeoff between smoothness and lag.
Ehlers proposes a nonlinear indicator as a solution to bridge the gap and achieve a smooth, timely response while reducing whipsaw trades.
The Synthetic oscillator adapts to market conditions by calculating a dynamic sine wave from the estimated instantaneous dominant cycle over a range of periods.
The process to calculate the indicator is as follows:
█ USAGE

This indicator displays the Synthetic Oscillator and a horizontal zero line in a separate pane. Users can analyze the crossings between the oscillator value and 0, or the behavior of the oscillator as it reaches 1 or -1, to derive potential timely trading signals.
Ehlers notes in the article that the peaks and valleys of the Synthetic Oscillator can provide signals a little too early, depending on the settings and context. Therefore, he recommends applying another smoother to the oscillator, such as a Hann Window filter with an optimizable length, to adjust timing as necessary.
█ INPUTS
This indicator uses multiple hardcoded parameters based on the implementation in Ehlers' article. However, users can customize the source series and the upper and lower bounds of the calculations:
This script implements a Synthetic Oscillator as presented by John F. Ehlers in the April 2026 TASC Traders' Tips article "Avoiding Whipsaw Trades". The indicator aims to provide a smooth, low-lag oscillator for timely trading signals by dynamically mapping a sine wave to price data.
█ CONCEPTS
"Whipsaw" trades are a common issue in algorithmic trading. They occur when the market quickly moves against a position, causing the trader/trading system to reverse their position at a loss, and then the market reverses again and continues in the original direction. Such trades occur because the trading system is attempting to react quickly to market moves instead of focusing on broader market cycles.
A typical solution for reducing whipsaw trades is to apply linear filters to smooth the data and emphasize specific cycles. However, linear filters cannot have both a smooth response and a low computational lag. Therefore, strategy designs utilizing linear filters require a tradeoff between smoothness and lag.
Ehlers proposes a nonlinear indicator as a solution to bridge the gap and achieve a smooth, timely response while reducing whipsaw trades.
The Synthetic oscillator adapts to market conditions by calculating a dynamic sine wave from the estimated instantaneous dominant cycle over a range of periods.
The process to calculate the indicator is as follows:
- Smooth the price data with a 12-bar Hann Window filter to reduce high-frequency noise, which can affect dominant cycle estimates.
- Band-pass filter the windowed data with a two-pole high-pass filter and a SuperSmoother filter to focus on the range of cycles between a specified lower bound and upper bound, and normalize the result using the filter's 100-bar root mean square (RMS).
- Calculate the one-bar rate of change (ROC) in the oscillator from step 2, and normalize the ROC using its 100-bar RMS.
- Estimate the instantaneous dominant cycle from the oscillators in steps 2 and 3 by treating the series as a complex waveform, where the first oscillator represents the waveform's band-limited "real" component ("I"), and the second represents the band-limited "imaginary" component ("Q").
- Cumulatively sum the reciprocal of the dominant cycle (i.e., the dominant frequency) to obtain the phase angle of the sine wave.
- To reduce cumulative errors and lag in the phase angle calculation, compute a secondary band-bass filter from a high-pass filter and the UltimateSmoother, and reset the angle to 0 or 180 degrees when that filter crosses above or below 0.
- Calculate the Synthetic Oscillator as the sine of the final phase angle.
█ USAGE
This indicator displays the Synthetic Oscillator and a horizontal zero line in a separate pane. Users can analyze the crossings between the oscillator value and 0, or the behavior of the oscillator as it reaches 1 or -1, to derive potential timely trading signals.
Ehlers notes in the article that the peaks and valleys of the Synthetic Oscillator can provide signals a little too early, depending on the settings and context. Therefore, he recommends applying another smoother to the oscillator, such as a Hann Window filter with an optimizable length, to adjust timing as necessary.
█ INPUTS
This indicator uses multiple hardcoded parameters based on the implementation in Ehlers' article. However, users can customize the source series and the upper and lower bounds of the calculations:
- Source Series: The series of values to process.
- Lower Bound: The smallest cycle in the passband of the filters, and the lower limit of the dominant cycle estimate.
- Upper Bound: The largest cycle in the passband of the filters, and the upper limit of the dominant cycle estimate.
릴리즈 노트
Bug Fix릴리즈 노트
Bug Fix: Hann Filter Corrected오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Tools and ideas for all Pine coders: tradingview.com/u/PineCoders/
TASC: traders.com/
TASC: traders.com/
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Tools and ideas for all Pine coders: tradingview.com/u/PineCoders/
TASC: traders.com/
TASC: traders.com/
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
