OPEN-SOURCE SCRIPT
Diupdate

Gaussian MA - Progressive Multi-Filter

169
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 ;)
Catatan Rilis
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 ;)

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.