Bayesian Trend Indicator
- Indicators
- Dominic Michael Frehner
- Version: 1.0
- Activations: 5
The Bayesian Trend Indicator colors each candle according to a Bayesian‐inference of trend direction. It computes “prior” trend strength from four standard moving averages (EMA, SMA, DEMA, VWMA) of your chosen length, then computes a “likelihood” from faster versions of those same MAs (shortened by a “gap”). It combines them to produce a posterior probability of an uptrend. Candles are colored:
-
Green when posterior indicates a strong uptrend.
-
Red when posterior indicates a strong downtrend.
-
Blue when posterior is neutral/uncertain.
This indicator combines the principles of Bayesian probability theory with moving average analysis to provide traders with a comprehensive understanding of market sentiment and potential trend reversals. The Bayesian Trend Indicator begins by calculating the trend for both fast and slow moving averages using a Smoothed Gradient Signal Function. This function assigns a numerical value to each data point based on its relationship with historical data, indicating the strength and direction of the trend.
You can read here more about the Bayes' Theorem: https://en.wikipedia.org/wiki/Bayes%27_theorem
Key Features
-
Bayesian-Based Trend Detection
Combines a “prior” trend estimate (from standard-length MAs) with a “likelihood” estimate (from faster MAs) via Bayes’ theorem to produce a robust posterior trend probability. -
Multi-MA Ensemble
Uses four different moving-average types—EMA, SMA, (pseudo-)DEMA, VWMA—for both slow and fast lengths, smoothing out idiosyncratic noise of any single MA. - Candle-Color Visualization
Paints chart candles in three distinct colors—uptrend (green), downtrend (red), neutral (blue)—making trend shifts immediately visible.
- Lightweight & Real-Time
All calculations occur on‐chart in real-time, with minimal performance overhead, suitable for any timeframe.
Indicator Parameters
- MA Lenght: Base MA length for prior probability calculation.
- Gap Lenght between fast and slow MA: Difference between base and fast MA lengths.
- Gap signals: Number of bars to look back when smoothing the signal.
- Short SMA Lenght: Length of short SMA (used internally).
- Long SMA Lenght: Length of long SMA (used internally).
Interpretation & Usage
-
Strong Uptrend (Green): Consider long entries or holding existing longs. Confirmation from other tools (e.g. RSI divergence) can improve reliability.
-
Strong Downtrend (Red): Consider short entries or exit longs. Use stops above recent swing highs.
-
Neutral (Blue): Market indecision. Best to stay flat or use range-trading strategies until trend clarifies.
This is not financial advice! This is a realtime indicator and doesn't repaint.