TradingView Indicators

TradingView FVG indicators: compare the rules behind the boxes

For an inspectable FVG indicator, Fair Value Gap [LuxAlgo] offers open source, a timeframe selector and gap-size filtering. FVG (Nephew_Sam_) documents wick/close fill settings and MTF support, but its source is protected. Choose by the detection and fill rules you need. This is a comparison of author documentation, not a chart-tested ranking or evidence that either indicator improves returns.

Build a custom FVG detector

The three-candle definition

Number the candles from oldest to newest. A bullish gap lies between candle 1 high and candle 3 low; a bearish gap lies between candle 3 high and candle 1 low. Candle 2 can trade through that interval, so an FVG is not proof that no trades occurred there. OHLC geometry also cannot identify who traded or establish the presence of unfilled institutional orders.

  • Equality at the boundary is not a gap under these strict inequalities.
  • Consequent Encroachment (CE) is the zone midpoint. Treating it as an entry level is a separate trading hypothesis.
  • The basic rule does not require high volume or a large candle 2. Add those filters explicitly if they belong to your definition.
RuleBullish FVGBearish FVG
Detection at candle 3 closelow > high[2]high < low[2]
Upper boundarylowlow[2]
Lower boundaryhigh[2]high
Midpoint (CE)(low + high[2]) / 2(low[2] + high) / 2

Touch, midpoint, full fill and invalidation

Choose the event before comparing indicator outputs. The rules below use a later candle, not the formation candle. For a bullish zone from 100 to 102, the touch threshold is 102, the midpoint is 101 and the full-fill threshold is 100. These are illustrative prices, not market observations.

  • Threshold crossing is not proof of trading at every price inside the zone. A session gap can jump over it.
  • A bullish later bar with low 101.5 triggers touch only; low 100.8 also triggers midpoint; low 99.8 triggers all three wick-based thresholds.
  • Decide whether to delete, stop extending or recolor a filled zone. The example stops extending and mutes it. It does not implement inverse-FVG transitions.
EventBullish conditionBearish conditionMeaning
Wick touchlow <= tophigh >= bottomPrice reaches or passes the near edge
Midpoint / CElow <= midpointhigh >= midpointPrice reaches or passes half the zone
Full filllow <= bottomhigh >= topPrice reaches or passes the far edge
Close-based invalidationclose < bottomclose > topA separate rule for a close beyond the far edge

Compare documented features, not unverified scores

The following comparison uses the linked authors' TradingView publications. We have not run these community scripts side by side or measured their repainting, speed or trading results. The suggested fit is an editorial inference from the documented controls; inspect the current settings before relying on them.

  • LuxAlgo documents an extra candle-2 close test and a size threshold. Its detections need not match a detector using only candle-1/candle-3 wick separation.
  • Protected source limits direct code review. It does not by itself show whether a script repaints.
  • No winner is assigned for profitability, alert delivery or speed because those were not measured here.
IndicatorDocumented controlsSource accessReason to inspect it
Fair Value Gap [LuxAlgo]Gap-height threshold, automatic threshold, timeframe selector, mitigation levels and fill alertsOpen sourceReviewable detection logic with timeframe and size controls
FVG (Nephew_Sam_)Wick or candle-close fill option, filled-zone deletion; release notes document MTF and alertsProtected sourceCompare wick-based and close-based lifecycle behavior
HTF Fair Value Gap [LuxAlgo]Higher-timeframe selector, latest-gap display and mitigation status dashboardOpen sourceFocus on higher-timeframe context rather than many overlapping boxes
Pine Script example on this pageChart timeframe, three fill thresholds, ATR-size filter, retained-zone cap and bar-close alertsFull example belowStart from explicit rules you can modify; no MTF or trade execution included

Higher-timeframe confirmation and drawing limits

A developing higher-timeframe candle can change while several chart candles close. TradingView documents requesting the previous HTF value with a one-bar expression offset and barmerge.lookahead_on to obtain consistent confirmed HTF values. This introduces confirmation delay. Using lookahead_on without the offset can leak future data into historical bars; lookahead_off alone is not a realtime confirmation guarantee.

  • For a custom MTF detector, calculate the three-candle condition in the requested timeframe, offset all requested fields consistently and create each HTF zone only once.
  • Require the selected timeframe to exceed the chart timeframe for an HTF-only implementation. Lower-timeframe requests have different intrabar behavior.
  • TradingView permits up to 500 boxes and 500 lines per script. Garbage collection deletes old drawings beyond the configured limits; it is not a substitute for a deliberate retention rule.
  • An ATR filter removes small zones according to a chosen threshold. It does not establish institutional activity or a measured improvement in win rate.

A chart-timeframe Pine Script v6 FVG detector

This educational example confirms new gaps and fill events at bar close. It processes existing zones before adding new ones, so a new gap cannot fill itself. Filled zones remain muted until the retention cap removes them. The cap includes both active and filled zones, and the drawing starts on the confirmation candle. ATR warmup bars produce no detections. Syntax validation does not establish chart behavior or trading performance.

  • Create a TradingView alert using this indicator and "Any alert() function call" to receive its event summaries. Adding a script alone does not create a running alert.
  • All events on one closing bar are combined in one message. A touch that occurs intrabar is reported at that bar's close.
  • Old active zones can be removed by the cap without being filled. A missing box therefore does not necessarily mean mitigation.
  • This is an indicator, not a strategy. It places no orders and calculates no win rate, stop loss or position size.
Complete example: three fill rules, bounded drawings and one event summary per barpinescript
//@version=6
indicator("Pineify FVG rules example", overlay = true, max_boxes_count = 100, max_lines_count = 100)

fillRule = input.string("Midpoint", "Fill rule", options = ["Touch", "Midpoint", "Full fill"])
atrLength = input.int(14, "ATR length", minval = 1)
minAtr = input.float(0.25, "Minimum gap / ATR", minval = 0, step = 0.05)
keepZones = input.int(25, "Retained zones (active and filled)", minval = 1, maxval = 100)

type Gap
    box area
    line midpointLine
    float top
    float bottom
    bool bullish
    bool active

var array<Gap> zones = array.new<Gap>()
float minimumSize = ta.atr(atrLength) * minAtr
bool bullishGap = low > high[2] and low - high[2] >= minimumSize
bool bearishGap = high < low[2] and low[2] - high >= minimumSize

if barstate.isconfirmed
    string events = ""
    // Only zones from earlier bars are eligible for a fill.
    for zone in zones
        if zone.active
            box.set_right(zone.area, time)
            line.set_x2(zone.midpointLine, time)
            float midpoint = (zone.top + zone.bottom) * 0.5
            float threshold = fillRule == "Midpoint" ? midpoint : fillRule == "Touch" ? (zone.bullish ? zone.top : zone.bottom) : (zone.bullish ? zone.bottom : zone.top)
            bool filled = zone.bullish ? low <= threshold : high >= threshold
            if filled
                zone.active := false
                box.set_bgcolor(zone.area, color.new(color.gray, 92))
                box.set_border_color(zone.area, color.new(color.gray, 65))
                line.set_color(zone.midpointLine, color.new(color.gray, 75))
                events += (zone.bullish ? "Bullish" : "Bearish") + " FVG reached " + fillRule + "; "

    if bullishGap or bearishGap
        // Delete before creating to stay within both drawing budgets.
        if array.size(zones) >= keepZones
            Gap oldest = array.shift(zones)
            box.delete(oldest.area)
            line.delete(oldest.midpointLine)
        float top = bullishGap ? low : low[2]
        float bottom = bullishGap ? high[2] : high
        float midpoint = (top + bottom) * 0.5
        color zoneColor = bullishGap ? color.teal : color.red
        box area = box.new(left = time, top = top, right = time, bottom = bottom, xloc = xloc.bar_time, border_color = zoneColor, bgcolor = color.new(zoneColor, 85))
        line midline = line.new(x1 = time, y1 = midpoint, x2 = time, y2 = midpoint, xloc = xloc.bar_time, color = zoneColor, style = line.style_dashed)
        array.push(zones, Gap.new(area, midline, top, bottom, bullishGap, true))
        events += (bullishGap ? "Bullish" : "Bearish") + " FVG created; "

    if str.length(events) > 0
        alert(events, alert.freq_once_per_bar_close)

A repeatable comparison checklist

Use this method before selecting a script. It is a proposed review procedure, not a report of tests completed for this page. Save screenshots with the symbol, exchange, timeframe, date range, session and inputs visible so differences can be reproduced.

  • Use ordinary candlesticks and identical chart settings. Begin with one timeframe and disable optional size filters where possible.
  • Mark several bullish and bearish three-candle patterns manually. Record which extra rules explain any missing or additional zones.
  • Follow each gap from formation through a shallow touch, midpoint and far-edge crossing. Check that the formation candle cannot immediately retire its own gap.
  • For MTF scripts, inspect when a zone first appears relative to the source candle close. Compare live observations with the chart after reload; historical screenshots alone cannot prove realtime stability.
  • Check retention limits and distinguish filled zones from zones removed by age or capacity. Test live alert delivery separately from chart drawing.
  • Evaluate a trading strategy separately with explicit execution rules, fees, slippage and an out-of-sample period. A visually useful detector is not evidence of a profitable strategy.
Where Pineify fits

Pine Script AI Coding Agent

Ask the coding agent to draft an FVG detector with your exact definition, fill rule, timeframe and retention policy. Review the generated code and test its chart and alert behavior before use.

Build a custom FVG detector

Frequently asked questions

Educational programming reference, not investment advice. FVG patterns do not guarantee fills, reversals or profitable trades. The comparison is based on publication documentation; no performance ranking or live execution test is claimed.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.