OPEN-SOURCE SCRIPT
KDJ Max-Distance (K-D vs K-J)

This indicator measures the maximum divergence between K and its related lines (D or J) in the KDJ stochastic system.
KEY CONCEPT:
- Calculates two distances: |K-D| and |K-J|
- Outputs whichever distance is larger
- Shows which component (D or J) is most diverged from K at any given time
CALCULATION:
1. Standard KDJ: K (fast), D (K smoothed), J (3K - 2D)
2. Distance K-D: momentum between fast and slow lines
3. Distance K-J: captures extreme divergence
4. Output: max(|K-D|, |K-J|) or signed version
INTERPRETATION:
• High positive values: K strongly above both D and J (strong upward momentum)
• High negative values: K strongly below both D and J (strong downward momentum)
• Near zero: K aligned with D/J (consolidation or reversal zone)
• Background color shows which is dominant: Teal=K-D, Orange=K-J
USE CASES:
- Identify extreme momentum conditions
- Spot divergence exhaustion
- Confirm trend strength
- Filter ranging vs trending markets
SETTINGS:
- Signed mode: preserves direction (positive/negative)
- Absolute mode: shows pure distance magnitude
- Adjustable guide levels for visual reference
KEY CONCEPT:
- Calculates two distances: |K-D| and |K-J|
- Outputs whichever distance is larger
- Shows which component (D or J) is most diverged from K at any given time
CALCULATION:
1. Standard KDJ: K (fast), D (K smoothed), J (3K - 2D)
2. Distance K-D: momentum between fast and slow lines
3. Distance K-J: captures extreme divergence
4. Output: max(|K-D|, |K-J|) or signed version
INTERPRETATION:
• High positive values: K strongly above both D and J (strong upward momentum)
• High negative values: K strongly below both D and J (strong downward momentum)
• Near zero: K aligned with D/J (consolidation or reversal zone)
• Background color shows which is dominant: Teal=K-D, Orange=K-J
USE CASES:
- Identify extreme momentum conditions
- Spot divergence exhaustion
- Confirm trend strength
- Filter ranging vs trending markets
SETTINGS:
- Signed mode: preserves direction (positive/negative)
- Absolute mode: shows pure distance magnitude
- Adjustable guide levels for visual reference
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.