OPEN-SOURCE SCRIPT

Particle Filter Pulse [forexobroker]

444
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.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.