OPEN-SOURCE SCRIPT
Variance Ratio & Efficiency Ratio (Quant Lab)

1️⃣ Variance Ratio (VR)
Formula:
VR ≈ Var(q-step returns) / (q × Var(1-step returns))
Interpretation:
• VR ≈ 1 → The market is like a random walk; neither trend nor mean-reversion is dominant.
• VR > 1 → Trend behavior is dominant.
• Trend-following systems (EMA, Supertrend, breakout) work better.
• VR < 1 → Mean-reversion is dominant.
• Range/reversal strategies (Z-score, Bollinger fade, RSI reversal) work better.
In short:
• VR > 1 → Trending market
• VR < 1 → Mean-reverting market
This tells you:
“Should I build a trend system or a mean-reversion system for this instrument?”
⸻
2️⃣ Efficiency Ratio (ER)
Formula logic:
ER = |Close_now – Close_n-bars-ago| / Σ|Close_i – Close_{i+1}|
In other words:
• Numerator → Net movement over N bars
• Denominator → Total noise over N bars
Interpretation:
• ER ≈ 1 → The price has moved in almost a straight line in one direction.
→ The trend is very efficient, noise is low.
• ER ≈ 0 → The price has fluctuated a lot but hasn't gone anywhere definitively.
→ A complete noise/range market.
This tells you:
“How clear is the trend in this last N bars, and how much noise is there?”
⸻
🔥 The intelligence provided by both together:
• VR > 1 and ER is high (0.6–1.0) →
➜ Strong, high-quality trend. Golden age for trend-following.
• VR > 1 but ER is low (0.2–0.4) →
➜ Trend exists but there is a lot of noise, many fake movements. • VR < 1 and ER is low →
➜ Net range / sideways market. Ideal for mean-reversion.
Formula:
VR ≈ Var(q-step returns) / (q × Var(1-step returns))
Interpretation:
• VR ≈ 1 → The market is like a random walk; neither trend nor mean-reversion is dominant.
• VR > 1 → Trend behavior is dominant.
• Trend-following systems (EMA, Supertrend, breakout) work better.
• VR < 1 → Mean-reversion is dominant.
• Range/reversal strategies (Z-score, Bollinger fade, RSI reversal) work better.
In short:
• VR > 1 → Trending market
• VR < 1 → Mean-reverting market
This tells you:
“Should I build a trend system or a mean-reversion system for this instrument?”
⸻
2️⃣ Efficiency Ratio (ER)
Formula logic:
ER = |Close_now – Close_n-bars-ago| / Σ|Close_i – Close_{i+1}|
In other words:
• Numerator → Net movement over N bars
• Denominator → Total noise over N bars
Interpretation:
• ER ≈ 1 → The price has moved in almost a straight line in one direction.
→ The trend is very efficient, noise is low.
• ER ≈ 0 → The price has fluctuated a lot but hasn't gone anywhere definitively.
→ A complete noise/range market.
This tells you:
“How clear is the trend in this last N bars, and how much noise is there?”
⸻
🔥 The intelligence provided by both together:
• VR > 1 and ER is high (0.6–1.0) →
➜ Strong, high-quality trend. Golden age for trend-following.
• VR > 1 but ER is low (0.2–0.4) →
➜ Trend exists but there is a lot of noise, many fake movements. • VR < 1 and ER is low →
➜ Net range / sideways market. Ideal for mean-reversion.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.