OPEN-SOURCE SCRIPT
SouthStone FVG Swing Levels

// Highlights swing highs/lows on a user-selected higher timeframe (default H1)
// that have had a Fair Value Gap (3-bar imbalance) form through them. These
// levels tend to act as high-probability retest targets because price
// "gapped" away from them and liquidity remains.
//
// All detection runs on the selected HTF. Lines use time-based x-coordinates
// so they render identically on ANY chart timeframe. On M5 / M15 / M1 the
// H1 levels remain visible, anchored at the actual pivot times.
//
// Logic (runs on HTF, results piped to chart TF):
// 1. Detect pivot highs and pivot lows on HTF via ta.pivothigh/low.
// 2. Store each pivot as "pending".
// 3. On each HTF bar, check if a new 3-bar FVG has formed:
// Bullish FVG: low[0] > high[2] -> gap = [high[2], low[0]]
// Bearish FVG: high[0] < low[2] -> gap = [high[0], low[2]]
// 4. For each pending pivot:
// a) If this HTF bar forms a valid FVG whose gap contains the pivot
// AND the FVG direction matches (bullish for swing highs, bearish
// for swing lows) -> draw line, pivot done.
// b) Else if the PREVIOUS HTF bar's range touched the pivot level
// without being claimed by an FVG here -> discard pivot forever.
// c) Else -> stay pending.
// 5. Lines extend forward until max line age (in HTF bars) is reached,
// then stop extending with a fixed right endpoint.
//
// Non-repainting HTF pattern: uses [1] offset with lookahead_on per v6
// best practice. Signals appear at the start of the NEXT HTF bar after
// the confirming one.
//
// - Default colours split: swing-high lines (bullish FVG break) now blue
// (#2196f3); swing-low lines (bearish FVG break) remain red (#ef5350).
// Both remain user-configurable.
//
// - Major rewrite for HTF support. All detection logic runs inside a
// request.security() function on the selected HTF, so H1 levels stay
// anchored in time across all chart timeframes.
// - Line x-coordinates switched to xloc.bar_time for cross-TF consistency.
// - maxAge / maxLineAge thresholds now expressed in HTF bars, converted
// internally to milliseconds for time-based comparisons.
// - Added HTF input (default "60" = H1).
// that have had a Fair Value Gap (3-bar imbalance) form through them. These
// levels tend to act as high-probability retest targets because price
// "gapped" away from them and liquidity remains.
//
// All detection runs on the selected HTF. Lines use time-based x-coordinates
// so they render identically on ANY chart timeframe. On M5 / M15 / M1 the
// H1 levels remain visible, anchored at the actual pivot times.
//
// Logic (runs on HTF, results piped to chart TF):
// 1. Detect pivot highs and pivot lows on HTF via ta.pivothigh/low.
// 2. Store each pivot as "pending".
// 3. On each HTF bar, check if a new 3-bar FVG has formed:
// Bullish FVG: low[0] > high[2] -> gap = [high[2], low[0]]
// Bearish FVG: high[0] < low[2] -> gap = [high[0], low[2]]
// 4. For each pending pivot:
// a) If this HTF bar forms a valid FVG whose gap contains the pivot
// AND the FVG direction matches (bullish for swing highs, bearish
// for swing lows) -> draw line, pivot done.
// b) Else if the PREVIOUS HTF bar's range touched the pivot level
// without being claimed by an FVG here -> discard pivot forever.
// c) Else -> stay pending.
// 5. Lines extend forward until max line age (in HTF bars) is reached,
// then stop extending with a fixed right endpoint.
//
// Non-repainting HTF pattern: uses [1] offset with lookahead_on per v6
// best practice. Signals appear at the start of the NEXT HTF bar after
// the confirming one.
//
// - Default colours split: swing-high lines (bullish FVG break) now blue
// (#2196f3); swing-low lines (bearish FVG break) remain red (#ef5350).
// Both remain user-configurable.
//
// - Major rewrite for HTF support. All detection logic runs inside a
// request.security() function on the selected HTF, so H1 levels stay
// anchored in time across all chart timeframes.
// - Line x-coordinates switched to xloc.bar_time for cross-TF consistency.
// - maxAge / maxLineAge thresholds now expressed in HTF bars, converted
// internally to milliseconds for time-based comparisons.
// - Added HTF input (default "60" = H1).
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.