OPEN-SOURCE SCRIPT
VPIN Flow Regime [OutOfSampleLab]

VPIN Flow Regime visualises order-flow toxicity and buy/sell pressure directly on your chart, with non-repainting flow-price divergence. It describes the current state of the tape. It does not give buy or sell signals.
How it works
- Each bar's volume is split into buy and sell parts using Bulk Volume Classification: the buy fraction is the CDF of the standardised close-to-close change. Two paper-faithful variants are selectable: the standard-normal CDF (Easley, Lopez de Prado & O'Hara, 2012) or the fat-tailed Student-t CDF with 0.25 degrees of freedom (their 2016 paper). To our knowledge no other public script offers both.
- VPIN toxicity = sum |buy - sell| / sum volume over N bars. An unsigned measure of how one-sided flow has been. It is coloured by its own rolling percentile into a regime light: Quiet, Normal, Elevated, Burst.
- Buy pressure = net flow rescaled to 0-100 (50 = balanced).
- Divergence: when price makes a higher high (or lower low) that net flow does not confirm. Confirmed on pivots a few bars later, so it never repaints. By default the divergence lines and labels are drawn directly on the price chart.
Alerts
- Toxicity crossing into Elevated / Burst / back to calm.
- Bullish / bearish flow-price divergence.
All alerts are state-change events, not trade instructions.
Honest limitations (please read)
- This is a bar-based approximation of VPIN, not tick-level VPIN on a true volume clock. Read relative levels and percentiles, not absolute values.
- TradingView volume is feed-dependent; on many FX/index/CFD symbols it is tick count, not traded volume, and the reading is weak there. Prefer symbols with real volume.
- Aggressor classification is imperfect and depends on the window settings.
This is an impersonal educational tool that runs the same for everyone. Not financial advice, no performance claims.
References: Easley, Lopez de Prado & O'Hara (2012), Review of Financial Studies 25(5); (2016), Journal of Financial Economics 120(2); Lee & Ready (1991), Journal of Finance 46(2).
How it works
- Each bar's volume is split into buy and sell parts using Bulk Volume Classification: the buy fraction is the CDF of the standardised close-to-close change. Two paper-faithful variants are selectable: the standard-normal CDF (Easley, Lopez de Prado & O'Hara, 2012) or the fat-tailed Student-t CDF with 0.25 degrees of freedom (their 2016 paper). To our knowledge no other public script offers both.
- VPIN toxicity = sum |buy - sell| / sum volume over N bars. An unsigned measure of how one-sided flow has been. It is coloured by its own rolling percentile into a regime light: Quiet, Normal, Elevated, Burst.
- Buy pressure = net flow rescaled to 0-100 (50 = balanced).
- Divergence: when price makes a higher high (or lower low) that net flow does not confirm. Confirmed on pivots a few bars later, so it never repaints. By default the divergence lines and labels are drawn directly on the price chart.
Alerts
- Toxicity crossing into Elevated / Burst / back to calm.
- Bullish / bearish flow-price divergence.
All alerts are state-change events, not trade instructions.
Honest limitations (please read)
- This is a bar-based approximation of VPIN, not tick-level VPIN on a true volume clock. Read relative levels and percentiles, not absolute values.
- TradingView volume is feed-dependent; on many FX/index/CFD symbols it is tick count, not traded volume, and the reading is weak there. Prefer symbols with real volume.
- Aggressor classification is imperfect and depends on the window settings.
This is an impersonal educational tool that runs the same for everyone. Not financial advice, no performance claims.
References: Easley, Lopez de Prado & O'Hara (2012), Review of Financial Studies 25(5); (2016), Journal of Financial Economics 120(2); Lee & Ready (1991), Journal of Finance 46(2).
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.