OPEN-SOURCE SCRIPT
Roll Spread Estimator [forexobroker]

Roll Spread Estimator implements Roll (1984) — the bid-ask bounce induces negative serial covariance in observed returns. Spread = 2 * sqrt(-cov(r[t], r[t-1])) when cov is negative. Tight spread = liquid market = clean breakouts; wide spread = thin = breakouts to fade. Signals fire on EMA cross during a tight regime. Stacked-flag visual signature distinct from any other hero indicator.
🔶 ALGORITHM
1. r0 = close - close[1]; r1 = close[1] - close[2].
2. cov(r0, r1) = sma(r0 * r1, N) - sma(r0, N) * sma(r1, N).
3. Spread = 2 * sqrt(-cov) when cov < 0; otherwise 0.
4. Quantile q (e.g., 70th percentile) over rolling window.
5. Tight regime when spread <= q.
6. EMA cross within tight fires entries.
🔶 SIGNAL LOGIC
- Buy: tight AND close crosses EMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: tight AND close crosses EMA down.
- Position-lock state machine.
🔶 INPUTS
- Cov Window (default 40)
- Tight Spread Quantile (default 0.7)
- Pullback EMA Length (default 8)
- Cooldown Bars (default 4)
- Visual: dashboard, glow (3 stacked flags), spread channel, buy / sell colors
🔶 ALERTS
RSE Buy, RSE Sell, RSE Any Signal, RSE Tight Start, RSE Tight End, RSE Bounce, RSE EMA Up, RSE EMA Down, RSE Webhook JSON.
🔶 LIMITATIONS
- Roll's estimator assumes the bid-ask bounce is the dominant source of negative covariance; trend-following autocorrelation can produce positive cov, in which case the estimator is undefined and returns 0.
- Forex and equities show clear bid-ask bounces; pure spot-market crypto is less consistent.
- The stacked-flag visual uses 3 overlapping flags for a thicker appearance — visually distinct but slightly heavier draw.
- Quantile-based threshold means tight is *relative* to recent history, not absolute.
🔶 ALGORITHM
1. r0 = close - close[1]; r1 = close[1] - close[2].
2. cov(r0, r1) = sma(r0 * r1, N) - sma(r0, N) * sma(r1, N).
3. Spread = 2 * sqrt(-cov) when cov < 0; otherwise 0.
4. Quantile q (e.g., 70th percentile) over rolling window.
5. Tight regime when spread <= q.
6. EMA cross within tight fires entries.
🔶 SIGNAL LOGIC
- Buy: tight AND close crosses EMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: tight AND close crosses EMA down.
- Position-lock state machine.
🔶 INPUTS
- Cov Window (default 40)
- Tight Spread Quantile (default 0.7)
- Pullback EMA Length (default 8)
- Cooldown Bars (default 4)
- Visual: dashboard, glow (3 stacked flags), spread channel, buy / sell colors
🔶 ALERTS
RSE Buy, RSE Sell, RSE Any Signal, RSE Tight Start, RSE Tight End, RSE Bounce, RSE EMA Up, RSE EMA Down, RSE Webhook JSON.
🔶 LIMITATIONS
- Roll's estimator assumes the bid-ask bounce is the dominant source of negative covariance; trend-following autocorrelation can produce positive cov, in which case the estimator is undefined and returns 0.
- Forex and equities show clear bid-ask bounces; pure spot-market crypto is less consistent.
- The stacked-flag visual uses 3 overlapping flags for a thicker appearance — visually distinct but slightly heavier draw.
- Quantile-based threshold means tight is *relative* to recent history, not absolute.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.