OPEN-SOURCE SCRIPT
Aktualisiert Gaussian MA - Progressive Multi-Filter

The previously published indicator based on Watson's Quadratic kernel was a bit complicated and "quadratic" in its calculations – it's an old indicator, and I've updated it a bit. I'm currently using Gaussian MA due to its simpler design and additional features that the former lacked.
Gaussian MA is an advanced trend-following indicator that combines statistical data smoothing with dynamic noise filtering. Here's a step-by-step analysis:
1. Gaussian Kernel Regression - the heart of the script is the gaussian_regression_max function. Instead of a simple average, it calculates a weight for each past price using a Gaussian distribution (bell curve):
Weights: Prices closest to the current candlestick have the greatest impact on the result, while those further away lose their importance exponentially.
The result: A very smooth line (yhat) that reacts faster than traditional moving averages while maintaining high resistance to short-term price spikes.
2. Progressive Volume Filter (ALMA Volume) - this is a unique part of the code that adjusts the indicator's sensitivity to market activity:
- the script calculates the moving average volume using the ALMA algorithm. The vol_ratio (current volume / average volume) is calculated.
Logic: If volume increases, the prog_factor decreases. This makes the filter thresholds "tighter," allowing the indicator to react more quickly to strong moves supported by high volume.
3. Dynamic Thresholds (Hysteresis) Instead of reacting to every change in the direction of the yhat line, the code calculates a "safety zone" (filter) that the price change must break through to signal a new trend:
- ATR: Threshold based on volatility (Average True Range).
- Percentage: Threshold percentage of the current price.
Both thresholds are multiplied by the previously mentioned prog_factor (volume).
4. Trend Detection and Visualization
Finally, the script compares the change in the regression value (diff) with the calculated thresholds:
- Bullish: If the change is positive and greater than the dynamic threshold.
- Bearish: If the change is negative and less than the negative threshold.
Result: The color of the line on the chart changes (green/red), and the alertcondition function allows you to set a notification when the color changes.
In short: Gaussian MA is an intelligent average that "knows" when the market is chaotic (it then increases the filtering thresholds) and when real momentum with volume is emerging (it then becomes more sensitive).
How to optimize the indicator parameters:
1. for the h parameter - (Lookback Window)
The h parameter controls the degree of regression smoothing. The higher the timeframe (e.g., Daily), the smaller h can be; on lower timeframes (e.g., 1m, 5m), you need more smoothing.
- For Scalping (1m - 5m): Set h in the range of 2.5 - 4.0. Noise on lower timeframes is high, so you need a "heavier" Gaussian kernel.
- For Day Trading (15m - 1h): Set h in the range of 1.5 - 2.5. This is the golden mean for ensuring liquidity without significant lag.
- For Swing (4h - Daily): Set h in the range of 0.75 - 1.5.
Trends on higher timeframes are stronger, so a smaller smoothing will allow for faster movement.
2. Calibrate vol_sens (Volume Sensitivity)
This parameter determines how much a "volume spike" facilitates a trend change.
- High Sensitivity (0.7 - 1.0): Aggressive approach. Even a small increase in trading volume will cause the indicator to react to price changes. Good for currency pairs with low liquidity.
- Low Sensitivity (0.1 - 0.4): Conservative approach. The indicator will ignore price movements unless accompanied by heavy volume (so-called "smart money"). Ideal for filtering out false positives (fakeouts).
It's safest to start with a setting of 0.5...
The above guidelines are indicative and are intended only to facilitate the use of the indicator - there are no perfect trading solutions; this indicator attempts to mathematically indicate points where entries/exits are statistically highly probable...
Works well with the MACD ALMA Edition ;)
Gaussian MA is an advanced trend-following indicator that combines statistical data smoothing with dynamic noise filtering. Here's a step-by-step analysis:
1. Gaussian Kernel Regression - the heart of the script is the gaussian_regression_max function. Instead of a simple average, it calculates a weight for each past price using a Gaussian distribution (bell curve):
Weights: Prices closest to the current candlestick have the greatest impact on the result, while those further away lose their importance exponentially.
The result: A very smooth line (yhat) that reacts faster than traditional moving averages while maintaining high resistance to short-term price spikes.
2. Progressive Volume Filter (ALMA Volume) - this is a unique part of the code that adjusts the indicator's sensitivity to market activity:
- the script calculates the moving average volume using the ALMA algorithm. The vol_ratio (current volume / average volume) is calculated.
Logic: If volume increases, the prog_factor decreases. This makes the filter thresholds "tighter," allowing the indicator to react more quickly to strong moves supported by high volume.
3. Dynamic Thresholds (Hysteresis) Instead of reacting to every change in the direction of the yhat line, the code calculates a "safety zone" (filter) that the price change must break through to signal a new trend:
- ATR: Threshold based on volatility (Average True Range).
- Percentage: Threshold percentage of the current price.
Both thresholds are multiplied by the previously mentioned prog_factor (volume).
4. Trend Detection and Visualization
Finally, the script compares the change in the regression value (diff) with the calculated thresholds:
- Bullish: If the change is positive and greater than the dynamic threshold.
- Bearish: If the change is negative and less than the negative threshold.
Result: The color of the line on the chart changes (green/red), and the alertcondition function allows you to set a notification when the color changes.
In short: Gaussian MA is an intelligent average that "knows" when the market is chaotic (it then increases the filtering thresholds) and when real momentum with volume is emerging (it then becomes more sensitive).
How to optimize the indicator parameters:
1. for the h parameter - (Lookback Window)
The h parameter controls the degree of regression smoothing. The higher the timeframe (e.g., Daily), the smaller h can be; on lower timeframes (e.g., 1m, 5m), you need more smoothing.
- For Scalping (1m - 5m): Set h in the range of 2.5 - 4.0. Noise on lower timeframes is high, so you need a "heavier" Gaussian kernel.
- For Day Trading (15m - 1h): Set h in the range of 1.5 - 2.5. This is the golden mean for ensuring liquidity without significant lag.
- For Swing (4h - Daily): Set h in the range of 0.75 - 1.5.
Trends on higher timeframes are stronger, so a smaller smoothing will allow for faster movement.
2. Calibrate vol_sens (Volume Sensitivity)
This parameter determines how much a "volume spike" facilitates a trend change.
- High Sensitivity (0.7 - 1.0): Aggressive approach. Even a small increase in trading volume will cause the indicator to react to price changes. Good for currency pairs with low liquidity.
- Low Sensitivity (0.1 - 0.4): Conservative approach. The indicator will ignore price movements unless accompanied by heavy volume (so-called "smart money"). Ideal for filtering out false positives (fakeouts).
It's safest to start with a setting of 0.5...
The above guidelines are indicative and are intended only to facilitate the use of the indicator - there are no perfect trading solutions; this indicator attempts to mathematically indicate points where entries/exits are statistically highly probable...
Works well with the MACD ALMA Edition ;)
Versionshinweise
Two additional filters have been added:SLOPE FILTER + Bollinger bands
The Slope Filter acts as a "lazy market detector." It checks whether the indicator line is moving steeply enough up or down to be considered a strong trend.
1. Calculating the "Speed" (raw_slope)
The script checks how much the Gaussian line has changed since the previous candle.
If the line increases by, for example, 10 points per candle, the slope is high.
If the line increases by, for example, 0.1 point, the slope is almost flat.
Formula: (change / price) * 1000. We normalize this so that the filter works the same on Bitcoin (expensive = large price jumps) and penny stocks (cheap = small price jumps).
2. Setting the "Barrier" (adaptive_min_slope)
The filter creates a "barrier" that the slope must break. Here it's intelligent (adaptive):
High volatility (noise): The barrier rises. The script requires a very strong slope to change the color, as the market is chaotic.
Low volatility (calm): The barrier falls. Even a slight slope is enough for the indicator to recognize it as a new trend.
3. Decision (slope_confirmed)
When the price breaks through the ATR threshold (which would normally change the indicator's color), the Slope Filter says: "STOP."
If slope > barrier: "Confirm, the trend is strong, change the color to green/red."
If slope < barrier: "Ignore this. This is a sideways trend; the line is too flat."
Why is this effective?
The main problem with moving averages is that in a sideways trend, the line "waves" and changes color constantly, generating lossy signals. The Slope Filter freezes the trend color until the regression line begins to clearly "climb" upwards or "fall" downwards. In summary: This is a quality filter for the movement. It prevents the indicator from reacting to price "creep," requiring it to have a firm direction.
BOLINGER BANDS with breakout markers from above and below:
It's quite simple:
- If it breaks from below, it means the Gaussian MA is losing momentum and entering the bands – a possible reversal to an uptrend or a correction in a downtrend.
- If it breaks from above, it means the Gaussian MA is losing momentum and returning to the bands – a possible downtrend or a correction in an uptrend.
And that's it - this indicator is almost complete as a standalone - by adding MACD to confirm the signals you get a combine harvester script that mows, threshes, collects grain and pours it into bags ;)
Versionshinweise
Fixes - possibly the final version:)NOTE:
Before using the AUTO-TUNE option, disable ALL filters so that the basic calculations for the Gaussian curve are performed on raw asset/stock price data.
1. Added the Auto_Tune function - enabling this option allows you to precisely select the number of samples for a given chart that will be analyzed to automatically determine the "Gaussian window" and the suggested ATR multiplier setting.
Both parameters are displayed in the table in the upper right corner of the screen.
NOTE - Auto-Tune does not calculate the "best number of samples" - these must be entered manually - to check the behavior of the Gaussian curve.
2. After the auto-tune module has completed the calculations, you can proceed to further MANUAL optimization using the remaining filters, the activation of which affects the drawing of the Gaussian curve on the chart (green/red lines).
Make adjustments using ONE filter at a time and check how the data has historically looked in the chart - so-called "Tune Filter" "visual backtest"
3. After completing the tests, you can disable auto-tune and permanently enter the suggested settings.
NOTE - data for a single asset/stock is not universal for all ;) - please keep this in mind.
Below are the suggested initial settings for various time intervals:
Prześlij opinię
1. Profile: Day Trading (Golden Mean)
Best for (5m, 15m, 1h) - focuses on catching intraday trends while maintaining liquidity.
- Auto-Tune: sample_size = 40, use_auto = true
- Slope Filter: min_slope = 1.2, low_vol_mode = true, vol_sens_adj = 1.0
- Volatility Filter: filter_mode = "ATR", atr_length = 7, atr_multiplier = 0.1
- Volume Filter: use_prog_vol = true, vol_sens = 0.5
- ALMA BB: alma_bb_len = 20, bb_mult = 1.8
2. Profile: Scalping (Fast Reaction) - for aggressive (trading 1m - 5m). Minimizes lag.
- Auto-Tune: sample_size = 20, use_auto = true
- Slope Filter: min_slope = 0.8, low_vol_mode = true, vol_sens_adj = 1.5
- Volatility Filter: filter_mode = "None" (allows for faster trend reversals)
- Volume Filter: use_prog_vol = true, vol_sens = 0.8 (strongly responds to volume spikes)
- ALMA BB: alma_bb_len = 20, bb_mult = 1.8
3. Profile: Swing Trading / Trend Following - for 4-hour and Daily time frames.
Resistant to noise, looks for large movements.
- Auto-Tune: sample_size = 80, use_auto = true
- Slope Filter: min_slope = 2.5, low_vol_mode = false (looking for pure momentum)
- Volatility Filter: filter_mode = "Both", perc_threshold = 0.35 (ATR is calculated automatically)
- Volume Filter: use_prog_vol = false (volume can be misleading on high timeframes)
- ALMA BB: alma_bb_len = 30, bb_mult = 2.0
Happy fishing!
Versionshinweise
final version with descriptions and range of settings in filter options ;)Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.