Indicator · Pine Script v6 · Own pane

AMFM - Ehlers AM Detector / FM Demodulator

by mihakralj

The AMFM indicator decomposes price movements into amplitude and frequency components using Ehlers' digital signal processing methods.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code50
Settings1inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

50 lines of Pine Script v6 from lib/cycles/amfm/amfm.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

amfm.pine
// AMFM: Ehlers AM Detector / FM Demodulator
// John F. Ehlers — "A Technical Description of Market Data for Traders"
// TASC, May 2021 (AM + FM) / June 2021 (strategy application)
// Source: https://www.mesasoftware.com/papers/AMFM.pdf
//
// Decomposes price movement into amplitude (AM) and frequency (FM) components
// using digital signal processing techniques from radio engineering.
//
// AM Detector: extracts volatility envelope from whitened spectrum
//   Deriv = Close - Open  (whitening — removes DC, handles gaps)
//   Envel = Highest(|Deriv|, 4)  (envelope detection)
//   AM = SMA(Envel, 8)  (smoothed volatility)
//
// FM Demodulator: extracts timing/phase from whitened spectrum
//   Deriv = Close - Open
//   HL = clamp(10 * Deriv, -1, +1)  (hard limiter — strips amplitude)
//   FM = SuperSmoother(HL, Period)  (integration via 2-pole Butterworth IIR)

//@version=6
indicator("AMFM - Ehlers AM Detector / FM Demodulator", shorttitle="AMFM",
     overlay=false, precision=4)

// ── Inputs ────────────────────────────────────────────────────────────
int period = input.int(30, "FM Super Smoother Period", minval=1)

// ── Common: Whitened derivative ───────────────────────────────────────
float deriv = close - open

// ── AM Detector ──────────────────────────────────────────────────────
float envel = ta.highest(math.abs(deriv), 4)
float am    = ta.sma(envel, 8)

// ── FM Demodulator ───────────────────────────────────────────────────
// Hard limiter: 10x gain then clamp to ±1 strips all amplitude info
float hl = math.max(-1.0, math.min(1.0, 10.0 * deriv))

// Super Smoother (2-pole Butterworth IIR) — integrates the hard-limited signal
float a1 = math.exp(-1.414 * math.pi / period)
float b1 = 2.0 * a1 * math.cos(1.414 * math.pi / period)
float c2 = b1
float c3 = -(a1 * a1)
float c1 = 1.0 - c2 - c3

var float fm = 0.0
fm := bar_index < 2 ? deriv : c1 * (hl + nz(hl[1])) / 2.0 + c2 * nz(fm[1]) + c3 * nz(fm[2])

// ── Plots ────────────────────────────────────────────────────────────
plot(am, "AM", color=color.new(color.orange, 0), linewidth=2)
plot(fm, "FM", color=color.new(color.aqua, 0), linewidth=2)
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)

Overview

AMFM - Ehlers AM Detector / FM Demodulator whitens the derivative as close minus open, then computes AM as the smoothed envelope of the absolute difference over 4 periods using SMA over 8. FM applies a hard limiter to 10 times the derivative before a Super Smoother with the set period. The primary input changes the FM Super Smoother Period. Plots AM in orange and FM in aqua on separate lines in a pane.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Volatility & bands, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
FM Super Smoother Periodint30period
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

318 stars

Calculates and plots moving averages on selected VIX volatility terms (VIX9D, VIX, VIX3M, or VIX6M) in a separate pane. The script computes user-defined short and long moving averages using EMA or SMA. It shades the background red when the short-term moving av

Indicator v5 Volatility & bandsMoving averages
Updated 2 months ago · MIT GitHub repository of [TVT] VIX Short Term Danger

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

This indicator plots a relative strength index in a separate pane. It calculates RSI from the average of the previous ten opens rather than the current bar, so that source does not change during the live candle. A moving average of the RSI is plotted and can b

Indicator v5 Oscillators & momentumMoving averages
Updated 2 years ago · None stated GitHub repository of No Repaint - Relative Strength Index

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers