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.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
🔵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.
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
🔵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.
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。