Güncellendi
[blackcat] L2 Perry Kaufman Adaptive MA (KAMA)

Level: 2
Background
Kaufman’s Adaptive Moving Average (KAMA) was developed by American quantitative financial theorist Perry J. Kaufman in 1998. The technique began in 1972 but Kaufman officially presented it to the public much later through his book, “Trading Systems and Methods.” Unlike other moving averages, Kaufman’s Adaptive Moving Average accounts not only for price action but also for market volatility. KAMA is a moving average that takes into account market noise or volatility. KAMA will closely track prices when price fluctuations are relatively small and noise is low. KAMA will adapt to increasing price fluctuations and track prices from a greater distance. This trend following indicator can be used to identify the overall trend, time turning points and to filter price movements.
Function
You can use KAMA like any other trend-following indicator, such as a moving average. You can look for price crosses, directional changes and filtered signals. First, a cross above or below KAMA indicates directional changes in prices. As with any moving average, a simple crossover system will generate lots of signals and lots of whipsaws. Second, You can use the direction of KAMA to define the overall trend for a security. This may require a parameter adjustment to smooth the indicator further. You can change the fastline and slowline parameters to smooth KAMA and look for directional changes. The trend is down as long as KAMA is falling and forging lower lows. The trend is up as long as KAMA is rising and forging higher highs. Finally, You can combine signals and techniques. You can use a longer-term KAMA to define the bigger trend and a shorter-term KAMA for trading signals.
I have included in the indicator an input named "EnableSmooth" that allows you to determine if the KAMA line should be smoothed or not. A "True" as the input value smoothes the calculation. An "False" simply plots the raw KAMA line. When market volatility is low, Kaufman’s Adaptive Moving Average remains near the current market price, but when volatility increases, it will lag behind. What the KAMA indicator aims to do is filter out “market noise” – insignificant, temporary surges in price action. One of the primary weaknesses of traditional moving averages is that when used for trading signals, they tend to generate many false signals. The KAMA indicator seeks to lessen this tendency – generate fewer false signals – by not responding to short-term, insignificant price movements. Traders generally use the moving average indicator to identify market trends and reversals.
Key Signal
AMAValF --> KAMA Fast Line.
AMAValS --> KAMA Slow Line.
Remarks
This is a Level 2 free and open source indicator.
Feedbacks are appreciated.
Background
Kaufman’s Adaptive Moving Average (KAMA) was developed by American quantitative financial theorist Perry J. Kaufman in 1998. The technique began in 1972 but Kaufman officially presented it to the public much later through his book, “Trading Systems and Methods.” Unlike other moving averages, Kaufman’s Adaptive Moving Average accounts not only for price action but also for market volatility. KAMA is a moving average that takes into account market noise or volatility. KAMA will closely track prices when price fluctuations are relatively small and noise is low. KAMA will adapt to increasing price fluctuations and track prices from a greater distance. This trend following indicator can be used to identify the overall trend, time turning points and to filter price movements.
Function
You can use KAMA like any other trend-following indicator, such as a moving average. You can look for price crosses, directional changes and filtered signals. First, a cross above or below KAMA indicates directional changes in prices. As with any moving average, a simple crossover system will generate lots of signals and lots of whipsaws. Second, You can use the direction of KAMA to define the overall trend for a security. This may require a parameter adjustment to smooth the indicator further. You can change the fastline and slowline parameters to smooth KAMA and look for directional changes. The trend is down as long as KAMA is falling and forging lower lows. The trend is up as long as KAMA is rising and forging higher highs. Finally, You can combine signals and techniques. You can use a longer-term KAMA to define the bigger trend and a shorter-term KAMA for trading signals.
I have included in the indicator an input named "EnableSmooth" that allows you to determine if the KAMA line should be smoothed or not. A "True" as the input value smoothes the calculation. An "False" simply plots the raw KAMA line. When market volatility is low, Kaufman’s Adaptive Moving Average remains near the current market price, but when volatility increases, it will lag behind. What the KAMA indicator aims to do is filter out “market noise” – insignificant, temporary surges in price action. One of the primary weaknesses of traditional moving averages is that when used for trading signals, they tend to generate many false signals. The KAMA indicator seeks to lessen this tendency – generate fewer false signals – by not responding to short-term, insignificant price movements. Traders generally use the moving average indicator to identify market trends and reversals.
Key Signal
AMAValF --> KAMA Fast Line.
AMAValS --> KAMA Slow Line.
Remarks
This is a Level 2 free and open source indicator.
Feedbacks are appreciated.
Sürüm Notları
OVERVIEWThis script implements the Perry Kaufman Adaptive Moving Average (KAMA) indicator, developed by blackcat1402. It provides traders with two customizable AMA lines: a fast and a slow line, which can be used to identify potential entry and exit points in the market. The indicator adapts its sensitivity based on market volatility, making it particularly useful during both trending and ranging conditions.
FEATURES
• Adaptive Moving Average (AMA) calculation with customizable periods
• Optional smoothing functionality for more refined signals
• Visual representation through colored AMA lines and fill areas
• Real-time trading signals with BUY/SELL labels
• Alert notifications for trading opportunities
HOW TO USE
Configure Parameters:
Set the Price Source (default: Close price)
Adjust Fast Period (default: 13)
Modify Slow Period (default: 55)
Toggle Smoothing option as needed
Interpret Signals:
Look for crossovers between fast and slow AMA lines
Green BUY signals appear when fast AMA crosses above slow AMA
Red SELL signals occur when fast AMA crosses below slow AMA
Visual Analysis:
Yellow line represents Fast AMA
Fuchsia line indicates Slow AMA
Colored fill area highlights potential trend direction
LIMITATIONS
• Indicator performance may vary across different timeframes and asset classes
• Best results achieved when combined with other technical analysis tools
• May generate false signals during high-volatility periods
NOTES
• Script requires minimum 5000 bars of historical data
• Compatible with TradingView's Pine Script v5
• Open-source code available under Mozilla Public License 2.0
Sürüm Notları
█ OVERVIEWThis indicator plots two Perry Kaufman Adaptive Moving Averages (KAMA) and trades their crossovers as a complete trend-following system. It adds position-state governance, ATR-based risk levels, and a live dashboard for chart-ready execution.
█ CONCEPTS
KAMA speeds up in trending markets and slows down in choppy ones, driven by an Efficiency Ratio: net price movement divided by total path traveled over the lookback. Clean trends yield a fast line; noise yields a slow one.
Key principles:
• Adaptive smoothing: the smoothing constant scales between fastest and slowest bounds with trend efficiency
• Dual-line crossover: fast and slow KAMA generate symmetric long and short signals
• Signal governance: a position state machine suppresses redundant same-direction entries and enforces a cooldown
• Volatility-based risk: take-profit and stop-loss levels derive from ATR multiples of the entry price
█ HOW TO USE
1 — Add the script to any chart; both AMA lines, the fill cloud, and the dashboard appear immediately
2 — Tune the Fast/Slow Period pair to the instrument's trend rhythm (defaults 13/55 suit swing timeframes)
3 — Read signals from the labels; track position, entry price, and risk levels in the dashboard
4 — Create TradingView alerts from any of the four alert conditions
Input Parameters
• Price Source: data used for AMA calculation (default: close)
• Fast Period: fast KAMA lookback (default: 13)
• Slow Period: slow KAMA lookback (default: 55)
• Fastest SC Period: fastest smoothing-constant period, classic value 2 (default: 2)
• Slowest SC Period: slowest smoothing-constant period, classic value 30 (default: 30)
• Enable Smoothing: extra linear-regression pass over each AMA line (default: off)
• Signal Governance: position state machine plus cooldown (default: on; off reproduces raw crossovers)
• Cooldown Bars: minimum bars between signals, 0 disables (default: 3)
• Show TP/SL Levels: toggles stop-loss and take-profit plots (default: on)
• ATR Length: lookback for the risk-level ATR (default: 14)
• Stop Loss (xATR): stop distance in ATR multiples (default: 2.0)
• Take Profit (xATR): target distance in ATR multiples (default: 3.0)
• Show Signal Labels / Position Background / Show Dashboard: visual toggles (all on by default)
█ FEATURES
• Symmetric long and short crossover signals with flip detection (FLIP suffix on reversal labels)
• ATR-based stop-loss and take-profit levels from entry to next signal
• Position state machine with configurable cooldown, exposed in the data window
• Color-coded position background for at-a-glance trend bias
• On-chart dashboard: position, entry price, ATR, stop-loss, and take-profit
• Four dedicated alert conditions plus dynamic price-stamped alerts, all close-confirmed
█ SIGNALS
Visual Elements
• Yellow line: Fast AMA; fuchsia line: Slow AMA; the shaded cloud shows which line leads
• Green BUY label below the bar: fast KAMA crossed above slow KAMA - potential long entry
• Red SELL label above the bar: fast KAMA crossed below slow KAMA - potential short entry
• FLIP suffix: the signal reversed an open position instead of opening from flat
• Red stepped line: stop-loss (entry - 2 ATR default); teal stepped line: take-profit (entry + 3 ATR default)
• Light green / light red background: long / short position state active
█ IMPLEMENTATION NOTES
Open-source under MPL 2.0. The KAMA engine is a series recursion over an efficiency-scaled smoothing constant with a zero-division guard. Built on ta.linreg, ta.atr, and ta.crossover/ta.crossunder, each evaluated every bar for series consistency. All alerts are close-confirmed to avoid intrabar repainting.
█ LIMITATIONS
• Adaptive averages underperform in prolonged ranges; expect whipsaw when the efficiency ratio stays low
• TP/SL lines are reference levels - the indicator does not place orders
• Governance reduces signal count; disable it to study raw crossover frequency
• Signals confirm at bar close; intrabar readings are not signal-accurate
█ NOTES
• KAMA concept by Perry J. Kaufman, "Trading Systems and Methods"
• blackcat1402 L2 series; MPL 2.0, attribution appreciated
═════════════════════════════════════════════════════════════════════════
For questions or feedback, use the comments section below.
This is not financial advice. Always test on a demo account first.
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
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
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
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.