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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
🔵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.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
🔵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.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.