OPEN-SOURCE SCRIPT
Illiquidity 1m gaps

// WHAT IT DOES
// Detects illiquid stocks by counting how often consecutive 1-minute bars
// fail to touch each other. On liquid names trades print continuously, so
// each bar's open is essentially equal to the previous bar's close. On
// illiquid names there are minutes with zero trades, and when a trade
// finally happens it can land at a meaningfully different price - leaving
// a visible gap between bars. Many such gaps in a session is a direct
// signal of thin liquidity.
//
// The indicator runs the 1-min gap analysis even when applied to higher
// timeframes (e.g. daily). Each daily candle is annotated with the total
// number of 1-min gaps that occurred during that session, broken into
// gap-ups and gap-downs. When the count exceeds the threshold, the
// display turns red.
//
// HOW IT WORKS
// 1. Fetches 1-minute data via request.security_lower_tf(), regardless
// of the chart's current timeframe.
// 2. For each 1-min bar, compares open to the prior close.
// 3. A gap is registered when |open - prevClose| / prevClose * 100
// exceeds the configured threshold.
// 4. Session-boundary jumps (overnight, lunch break) are excluded by
// checking the time delta between consecutive bars - only bars less
// than 5 minutes apart in real time are considered.
// 5. Gaps are summed across all 1-min bars within the current chart bar.
//
// INPUTS
// - Min gap size pct: Minimum price jump (% of price) that counts as a
// gap. Default 0.10%. Increase for cheap stocks (<Rs.100 use 0.20%),
// decrease for high-priced names (>Rs.3000 use 0.05%).
// - Gaps per chart bar to flag illiquid: Threshold above which the bar
// is marked red. Suggested starting values by category:
// Nifty 50 / large caps : 10
// Mid caps : 20 (default)
// Small caps : 35
// Microcaps / SME : 60+
// - Show on chart (table): Toggle the corner table.
// - Show in status line: Toggle the three numbers in TradingView's
// status line (Total / Up / Down).
// - Table position: 9-way position picker (top/middle/bottom x
// left/center/right).
// - Text size: Tiny / Small / Normal / Large.
//
// DISPLAY
// - Table shows: "<total>g <up>u <down>d" e.g. "14g 8u 6d".
// - Status line shows the same three numbers as separate plot values.
// - Background of the readout flips red when total >= threshold.
//
// LIMITATIONS
// - TradingView caches a limited amount of lower-timeframe history. On
// a daily chart pulling 1-min data, typically only the most recent
// 10-40 trading days will populate accurately. Older bars may show
// zero gaps because the 1-min data is unavailable, not because the
// stock was liquid.
// - Free/Basic plans have stricter intrabar limits than paid plans.
// - Works best on equity instruments with regular sessions. For 24/7
// markets (crypto), the session-boundary filter is unused.
//
// USE CASE
// Screen out illiquid stocks before adding them to a watchlist or sizing
// into a position. Apply this indicator to your daily chart, glance at
// the corner readout, and skip any name flagged red - the spread and
// slippage on those will eat your edge.
//
// CALIBRATION
// Apply to three reference tickers on your daily chart:
// - A known liquid name (RELIANCE) - should read ~0-5 gaps.
// - A midcap you actually trade - note the typical count.
// - A microcap or SME - should read 50+.
// Set your threshold to roughly 2x the typical count of your tradeable
// midcap.
// =============================================================================
// Detects illiquid stocks by counting how often consecutive 1-minute bars
// fail to touch each other. On liquid names trades print continuously, so
// each bar's open is essentially equal to the previous bar's close. On
// illiquid names there are minutes with zero trades, and when a trade
// finally happens it can land at a meaningfully different price - leaving
// a visible gap between bars. Many such gaps in a session is a direct
// signal of thin liquidity.
//
// The indicator runs the 1-min gap analysis even when applied to higher
// timeframes (e.g. daily). Each daily candle is annotated with the total
// number of 1-min gaps that occurred during that session, broken into
// gap-ups and gap-downs. When the count exceeds the threshold, the
// display turns red.
//
// HOW IT WORKS
// 1. Fetches 1-minute data via request.security_lower_tf(), regardless
// of the chart's current timeframe.
// 2. For each 1-min bar, compares open to the prior close.
// 3. A gap is registered when |open - prevClose| / prevClose * 100
// exceeds the configured threshold.
// 4. Session-boundary jumps (overnight, lunch break) are excluded by
// checking the time delta between consecutive bars - only bars less
// than 5 minutes apart in real time are considered.
// 5. Gaps are summed across all 1-min bars within the current chart bar.
//
// INPUTS
// - Min gap size pct: Minimum price jump (% of price) that counts as a
// gap. Default 0.10%. Increase for cheap stocks (<Rs.100 use 0.20%),
// decrease for high-priced names (>Rs.3000 use 0.05%).
// - Gaps per chart bar to flag illiquid: Threshold above which the bar
// is marked red. Suggested starting values by category:
// Nifty 50 / large caps : 10
// Mid caps : 20 (default)
// Small caps : 35
// Microcaps / SME : 60+
// - Show on chart (table): Toggle the corner table.
// - Show in status line: Toggle the three numbers in TradingView's
// status line (Total / Up / Down).
// - Table position: 9-way position picker (top/middle/bottom x
// left/center/right).
// - Text size: Tiny / Small / Normal / Large.
//
// DISPLAY
// - Table shows: "<total>g <up>u <down>d" e.g. "14g 8u 6d".
// - Status line shows the same three numbers as separate plot values.
// - Background of the readout flips red when total >= threshold.
//
// LIMITATIONS
// - TradingView caches a limited amount of lower-timeframe history. On
// a daily chart pulling 1-min data, typically only the most recent
// 10-40 trading days will populate accurately. Older bars may show
// zero gaps because the 1-min data is unavailable, not because the
// stock was liquid.
// - Free/Basic plans have stricter intrabar limits than paid plans.
// - Works best on equity instruments with regular sessions. For 24/7
// markets (crypto), the session-boundary filter is unused.
//
// USE CASE
// Screen out illiquid stocks before adding them to a watchlist or sizing
// into a position. Apply this indicator to your daily chart, glance at
// the corner readout, and skip any name flagged red - the spread and
// slippage on those will eat your edge.
//
// CALIBRATION
// Apply to three reference tickers on your daily chart:
// - A known liquid name (RELIANCE) - should read ~0-5 gaps.
// - A midcap you actually trade - note the typical count.
// - A microcap or SME - should read 50+.
// Set your threshold to roughly 2x the typical count of your tradeable
// midcap.
// =============================================================================
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.