PROTECTED SOURCE SCRIPT
Diupdate Bayesian Particle Bars [Jamallo]

Intro
The Bayesian Particle Bars indicator is an advanced tracking algorithm that merges Bayesian estimation (Particle Filtering) with Chaos Theory (Permutation Entropy).
Instead of viewing price through the rigid structure of traditional candlesticks—which only offer a static summary of past (open, high, low, and close) data—this script re-imagines price action as a dynamic, probabilistic 'swarm' of mathematical particles. Each particle tries to guess the next price based on its own velocity and random noise. The script then evaluates how accurate each particle was, assigning higher "weights" to those closest to the actual price, ultimately calculating a consensus line (the Weighted Mean) that represents the "true" underlying price of the asset.
Breakdown
The Particle Swarm (Prediction & Update)
The script uses an array of up to 20 "particles." Each particle acts as an independent price estimator with its own position and velocity.
Permutation Entropy (Adaptive Noise Scaling)
One of the most unique features of this script is its dynamic adjustment of process and measurement noise using Permutation Entropy (PE).
If the market is trending smoothly, entropy is low. If the market is choppy and unpredictable, entropy is high. The script scales the random noise injected into the particles based on this entropy. In a chaotic market, the particles spread out wider to account for the uncertainty.
Bayesian Weighting (Measurement)
Once the particles make their predictions, the script measures reality against the guesses.
The Consensus (Weighted Mean)
Finally, the script calculates the `pf_mean`. It multiplies each particle's position by its respective weight and divides by the total sum of weights. This produces the Weighted Mean Line, a dynamic, low-lag curve that tracks the consensus of the most accurate particles
The Bayesian Particle Bars indicator is an advanced tracking algorithm that merges Bayesian estimation (Particle Filtering) with Chaos Theory (Permutation Entropy).
Instead of viewing price through the rigid structure of traditional candlesticks—which only offer a static summary of past (open, high, low, and close) data—this script re-imagines price action as a dynamic, probabilistic 'swarm' of mathematical particles. Each particle tries to guess the next price based on its own velocity and random noise. The script then evaluates how accurate each particle was, assigning higher "weights" to those closest to the actual price, ultimately calculating a consensus line (the Weighted Mean) that represents the "true" underlying price of the asset.
Breakdown
The Particle Swarm (Prediction & Update)
The script uses an array of up to 20 "particles." Each particle acts as an independent price estimator with its own position and velocity.
- Prediction Step: Every bar, each particle projects where the price will go based on its previous trajectory (`prev_v`) decayed by a momentum factor (`pf_velocity_decay`), and injected with a dose of random Gaussian noise (`f_gaussian`).
- Anchoring: To prevent particles from drifting infinitely away into space (a common issue in particle filters without a resampling step), the script applies an `pf_anchor_strength` variable. This gently tethers the particles back toward the actual closing price, acting like a gravitational pull.
Permutation Entropy (Adaptive Noise Scaling)
One of the most unique features of this script is its dynamic adjustment of process and measurement noise using Permutation Entropy (PE).
- Pattern Recognition: The`f_getPattern` function evaluates every 3-bar sequence of closing prices and categorizes it into one of 6 possible ordinal patterns (e.g., up-up-up, down-up-down).
- Shannon Entropy: It counts the frequency of these patterns over the lookback window (peLength) and calculates the normalized Shannon Entropy.
If the market is trending smoothly, entropy is low. If the market is choppy and unpredictable, entropy is high. The script scales the random noise injected into the particles based on this entropy. In a chaotic market, the particles spread out wider to account for the uncertainty.
Bayesian Weighting (Measurement)
Once the particles make their predictions, the script measures reality against the guesses.
- Using the `f_weight` function, the script calculates the error between the particle's predicted price and the actual `close`
- It uses an inverse-square relationship: `1.0 / (1.0 + err * err)` Particles that guess closely receive a heavily weighted "vote," while inaccurate particles are largely ignored.
The Consensus (Weighted Mean)
Finally, the script calculates the `pf_mean`. It multiplies each particle's position by its respective weight and divides by the total sum of weights. This produces the Weighted Mean Line, a dynamic, low-lag curve that tracks the consensus of the most accurate particles
Catatan Rilis
Fixed grey particles size bug on low res monitorsCatatan Rilis
- code clean up & minor fixes Skrip terproteksi
Skrip ini diterbitkan sebagai sumber tertutup. Namun, Anda dapat menggunakannya dengan bebas dan tanpa batasan apa pun – pelajari lebih lanjut di sini.
Join the Growing (Econophysics Trading) Community! ⚛️
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
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.
Skrip terproteksi
Skrip ini diterbitkan sebagai sumber tertutup. Namun, Anda dapat menggunakannya dengan bebas dan tanpa batasan apa pun – pelajari lebih lanjut di sini.
Join the Growing (Econophysics Trading) Community! ⚛️
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
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.