Bro_Sheep

[BKong] Filtered Adaptive Moving Average

### Introduction
The Filtered Adaptive Moving Average (BKMA) indicator is a moving average based on adaptive algorithms. It combines a Kalman filter and volume-weighted smoothing methods, allowing it to more sensitively capture price trend changes in volatile markets while reducing noise interference. This indicator is highly flexible and adaptive due to its various parameter configurations.

### Indicator Parameters
- **AMA Period (ama_length):** This parameter determines the base period of the adaptive moving average. The default value is 3. The shorter the period, the more sensitive the indicator is to price changes.
- **Sensitivity (sensitivity):** This parameter adjusts the sensitivity of the Kalman filter, ranging from 0.1 to 2.0. The higher the sensitivity, the faster the indicator responds to price changes.
- **Noise Reduction (noise_reduction):** This parameter reduces the market noise interference on the indicator, ranging from 0.0 to 1.0. The higher the noise reduction value, the stronger the indicator's filtering effect on price fluctuations.
- **Source (src):** This parameter allows users to select the price data used to calculate the indicator, with the default value being the closing price.
- **Volume Weighted Smoothing Length (volume_weight_length):** This parameter defines the period length for volume-weighted smoothing, with a default value of 10. The longer the period, the more pronounced the smoothing effect.
- **Smoothing Factor (smooth_factor):** This parameter adjusts the sensitivity of the smoothed indicator, ranging from 0.0 to 1.0. The higher the smoothing factor, the smoother the indicator.

### Calculation Process
1. **Adaptive Period Adjustment:** The adaptive period is calculated using ATR (Average True Range) and HMA (Hull Moving Average) to allow the indicator to dynamically adapt to market volatility.
2. **Kalman Filter Parameters Calculation:**
- **Efficiency Ratio (efficiency_ratio):** This evaluates the effectiveness of the current price changes.
- **Kalman Filter Gain (kf_gain) and Noise Parameters (kf_noise):** These are adjusted based on the efficiency ratio.
3. **Kalman Filter Update:** The Kalman filter is used to update price data to reduce market noise.
4. **Volatility Calculation:** Market volatility is calculated using ATR values and Kalman filter parameters.
5. **Adaptive Moving Average (AMA) Calculation:** The adaptive moving average is calculated using the updated Kalman filter values and volatility.
6. **Volume Weighted Smoothing:** A custom volume-weighted smoothing function is used to smooth the changes in the adaptive moving average.
7. **Smoothed Plot Line:** WMA (Weighted Moving Average) is used to further smooth the adaptive moving average for a more consistent plot.
8. **Color Determination:** The color of the indicator line is determined based on the smoothed changes in the adaptive moving average. If the change is greater than zero, the line is green, indicating an upward trend. If the change is less than zero, the line is red, indicating a downward trend.

### Plotting and Application
1. **Plotting the Smoothed AAMA Line:** The adaptive moving average is further smoothed using WMA and plotted with the calculated color values. The line width is set to 2 for clear visibility on the chart.
2. **Application Scenarios:**
- **Trend Judgement:** Users can visually determine the market's upward or downward trend based on color changes.
- **Trading Decisions:** A transition from red to green may indicate a buy signal, while a transition from green to red may indicate a sell signal.
- **Noise Filtering:** By adjusting the noise reduction parameter, users can minimize the impact of short-term market fluctuations on trading decisions, improving the accuracy of trading signals.

Protected script
This script is published closed-source but you may use it freely. You can favorite it to use it on a chart. You cannot view or modify its source code.
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?