OPEN-SOURCE SCRIPT
KAMA Adaptive Trend System (Risk-Managed)

Overview
This script is a professional-grade adaptation of the Kaufman Adaptive Moving Average (KAMA). While standard KAMA scripts focus solely on price smoothing, this version (V5) is designed as a complete trading system with a focus on institutional-style risk management and trend hygiene.
How It Works
The strategy uses a three-layer confirmation process before entering a trade:
Key Features
How to Use
Bullish Setup: KAMA turns green, price is > 200 SMA, and RSI > 50.
Bearish Setup: KAMA turns red, price is < 200 SMA, and RSI < 50.
Settings: You can toggle the "Order Direction" to focus on Long-only or Short-only setups depending on your market bias.
Credits
Based on the original KAMA logic by tradedots. Modifications by Gemini Assistant include risk management integration and alert logic optimization.
This script is a professional-grade adaptation of the Kaufman Adaptive Moving Average (KAMA). While standard KAMA scripts focus solely on price smoothing, this version (V5) is designed as a complete trading system with a focus on institutional-style risk management and trend hygiene.
How It Works
The strategy uses a three-layer confirmation process before entering a trade:
- The Core (KAMA): Tracks price efficiency to identify trend shifts.
- The Regime Filter: A 200-period SMA ensures you are only trading with the long-term trend (Longs above, Shorts below).
- Momentum Filter: An RSI check (Midline 50) confirms there is actual strength behind the move.
Key Features
- Dynamic Position Sizing: Automatically calculates quantity based on a fixed % of account equity (default 1%).
- ATR-Based Volatility Stops: Uses a 2.5x ATR multiplier to set hard stop-losses that breathe with market volatility.
- Smart Alerts: Alerts are programmed to trigger on KAMA Color Changes only. This prevents "alert fatigue" caused by fluctuating filters while keeping you informed of trend flips.
How to Use
Bullish Setup: KAMA turns green, price is > 200 SMA, and RSI > 50.
Bearish Setup: KAMA turns red, price is < 200 SMA, and RSI < 50.
Settings: You can toggle the "Order Direction" to focus on Long-only or Short-only setups depending on your market bias.
Credits
Based on the original KAMA logic by tradedots. Modifications by Gemini Assistant include risk management integration and alert logic optimization.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.