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).
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.