OPEN-SOURCE SCRIPT
Particle Filter Pulse [forexobroker]

Particle Filter Pulse runs a sequential Monte Carlo (32-particle) filter that tracks a hidden trend through Gaussian likelihood updates and effective-sample-size resampling. Particles use deterministic jitter — no random number generation, fully reproducible. When ESS collapses below the threshold, the filter resamples around the current price, marking a regime shift, and a fresh trend can lock in.
🔶 ALGORITHM
1. 32 particles each carry (price, velocity). Initialised at first bar with a deterministic spread around close.
2. Predict: each particle is propagated by its velocity plus a small ATR-scaled deterministic perturbation.
3. Likelihood: weight w_k *= exp(-0.5 * (close - px_k)^2 / sigma^2) with sigma = ATR.
4. Normalise weights. ESS = 1 / sum(w_k^2).
5. Resample when ESS < N * k: re-centre all particles at close and reset weights.
6. Filter mean = sum(w_k * px_k); velocity = sum(w_k * vx_k).
🔶 SIGNAL LOGIC
- Buy: close > filter mean AND velocity > 0 AND close crosses EMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: close < filter mean AND velocity < 0 AND close crosses EMA down.
- Position-lock state machine.
🔶 INPUTS
- Jitter (% of ATR) (default 0.30)
- ESS Collapse Fraction (default 0.50)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, filter mean line, buy / sell colors
🔶 ALERTS
PFP Buy, PFP Sell, PFP Any Signal, PFP Resample, PFP Trend Up, PFP Trend Down, PFP EMA Up, PFP EMA Down, PFP Webhook JSON.
🔶 LIMITATIONS
- 32 particles is a small ensemble; the filter is qualitatively similar to a 1D Kalman in most regimes. The advantage shows in non-Gaussian / multimodal posteriors.
- Deterministic jitter trades randomness for reproducibility; for true SMC use offline Python tooling with RNG.
- Filter auto-recovers from symbol changes via a 20-ATR divergence guard but takes a few bars to relock.
- The Gaussian likelihood assumes stationary noise; heavy-tail spikes momentarily collapse all weights and trigger resampling.
🔶 ALGORITHM
1. 32 particles each carry (price, velocity). Initialised at first bar with a deterministic spread around close.
2. Predict: each particle is propagated by its velocity plus a small ATR-scaled deterministic perturbation.
3. Likelihood: weight w_k *= exp(-0.5 * (close - px_k)^2 / sigma^2) with sigma = ATR.
4. Normalise weights. ESS = 1 / sum(w_k^2).
5. Resample when ESS < N * k: re-centre all particles at close and reset weights.
6. Filter mean = sum(w_k * px_k); velocity = sum(w_k * vx_k).
🔶 SIGNAL LOGIC
- Buy: close > filter mean AND velocity > 0 AND close crosses EMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: close < filter mean AND velocity < 0 AND close crosses EMA down.
- Position-lock state machine.
🔶 INPUTS
- Jitter (% of ATR) (default 0.30)
- ESS Collapse Fraction (default 0.50)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, filter mean line, buy / sell colors
🔶 ALERTS
PFP Buy, PFP Sell, PFP Any Signal, PFP Resample, PFP Trend Up, PFP Trend Down, PFP EMA Up, PFP EMA Down, PFP Webhook JSON.
🔶 LIMITATIONS
- 32 particles is a small ensemble; the filter is qualitatively similar to a 1D Kalman in most regimes. The advantage shows in non-Gaussian / multimodal posteriors.
- Deterministic jitter trades randomness for reproducibility; for true SMC use offline Python tooling with RNG.
- Filter auto-recovers from symbol changes via a 20-ATR divergence guard but takes a few bars to relock.
- The Gaussian likelihood assumes stationary noise; heavy-tail spikes momentarily collapse all weights and trigger resampling.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。