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.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
🔵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.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
🔵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.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.