OPEN-SOURCE SCRIPT

Bayesian Trend

987
English Description (primary)

1. Overview
This script implements a Naive Bayesian classifier to estimate the probability of an upcoming bullish, bearish, or neutral move. It combines multiple indicators—RSI, MACD histogram, EMA price difference in ATR units, ATR level vs. its average, and Volume vs. its average—to calculate likelihoods for each market direction. Each indicator is “binned” (categorized into discrete zones) and assigned conditional probabilities for bullish/bearish/neutral scenarios. The script then normalizes these probabilities and paints bars in green if bullish is most likely, red if bearish is most likely, or blue if neutral is most likely. A small table is also displayed in the top-right corner of the chart, showing real-time probabilities.

2. How it works

Indicator Calculations: The script calculates RSI, MACD (line and histogram), EMA, ATR, and Volume metrics.
Binning: Each metric is converted into a discrete category (e.g., low, medium, high). For example, RSI < 30 is binned as “low,” while RSI > 70 is binned as “high.”
Conditional Probabilities: User-defined tables specify the conditional probabilities of each bin under three hypotheses (Up, Down, Neutral).
Naive Bayesian Formula: The script multiplies the relevant conditional probabilities, normalizes them, and derives the final probabilities (Up, Down, or Neutral).
Visualization:
Bar Colors: Bars are green when the Up probability exceeds 50%, red for Down, and blue otherwise.
Table: Displays numeric probabilities of Up, Down, and Neutral in percentage terms.

3. How to use it

Add the script to your chart.
Observe the colored bars:
Green suggests a higher probability for bullish movement.
Red suggests a higher probability for bearish movement.
Blue indicates a higher probability of sideways or uncertain conditions.
Check the table in the top-right corner to see exact probabilities (Up/Down/Neutral).
Use the input settings to adjust thresholds (RSI, MACD, Volume, etc.), define alert conditions (e.g., when Up probability crosses 50%), and decide whether to trigger alerts on bar close or in real-time.

4. Originality and usefulness

Originality: This script uniquely applies a Naive Bayesian approach to a blend of classic and volume-based indicators. It demonstrates how different indicator “zones” can be combined to produce probabilistic insights.
Usefulness: Traders can interpret the probability breakdown to gauge the script’s bias. Unlike single indicators, this approach synthesizes several signals, potentially offering a more holistic perspective on market conditions.

5. Limitations

The conditional probabilities are manually assigned and may not reflect actual market behavior across all instruments or timeframes.
Results depend on the user’s choice of thresholds and indicator settings.
Like any indicator, past performance does not guarantee future results. Always confirm signals with additional analysis.
6. Disclaimer
This script is intended for educational and informational purposes only. It does not constitute financial advice. Trading involves significant risk, and you should make decisions based on your own analysis. Neither the script’s author nor TradingView is liable for any financial losses.

Русское описание (Russian translation, optional)

Этот индикатор реализует наивный Байесовский классификатор для оценки вероятности предстоящего роста (Up), падения (Down) или бокового движения (Neutral). Он комбинирует несколько индикаторов—RSI, гистограмму MACD, разницу цены и EMA в единицах ATR, уровень ATR относительно своего среднего значения и объём относительно своего среднего—чтобы вычислить вероятности для каждого направления рынка. Каждый индикатор делится на «зоны» (low, mid, high), которым приписаны условные вероятности для бычьего/медвежьего/нейтрального исхода. Скрипт нормирует эти вероятности и раскрашивает бары в зелёный, красный или синий цвет в зависимости от того, какая вероятность выше. Также в правом верхнем углу отображается таблица с текущими значениями вероятностей.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.