OPEN-SOURCE SCRIPT
FVG Handoff [scriptedge]

Overview
FVG Handoff looks for a fair value gap on a higher timeframe, then waits to see whether price returns to that gap on the very next higher timeframe candle. Throughout this description the three candles that form the gap are called the context candles, and the one after them is the trading candle.
The indicator is designed so that the whole setup can be visualised from the lower timeframe you intend to trade. The higher timeframe is read in the background and its structure is drawn onto your chart, so there is no need to switch timeframes to see where the gap sits or how the trading candle is developing. Any confirmation the indicator marks is one that occurred on your own chart timeframe, within the span of the trading candle.

The tool draws structure and context. It does not generate buy or sell signals, and it does not manage entries, exits, stops, or position size. Those decisions are left to the trader.
The Higher Timeframe Pattern
A fair value gap is a three candle pattern where the first and third context candles do not overlap.
The gap between the first and third context candles is the zone. It is drawn on your chart as a shaded box.

The target is the furthest extreme of the second and third context candles — the highest high on a bullish pattern, the lowest low on a bearish one. The second is the impulse candle and often overshoots the third, which is why both are considered rather than the third alone.

Why Only The Next Candle
Most fair value gap tools keep a gap on the chart indefinitely and mark it whenever price eventually returns, which can be days later. This indicator only considers the immediately following higher timeframe candle — the trading candle.
Everything happens within it:
This is a deliberate narrowing, not an oversight. It selects for gaps that the market reacts to immediately rather than gaps that happen to be revisited much later.
Lower Timeframe Confirmations
Once the zone has been tapped, the indicator looks for a confirmation on your chart timeframe, within the trading candle. Each type fires at most once per setup, and each can be turned on or off independently.
FVG — a fair value gap in the same direction as the setup forming on the chart timeframe, in other words price leaving the higher timeframe zone with a gap of its own. Drawn as a box over the three candles that formed it.

IFVG — a gap in the opposite direction that price then closes back through, inverting it. A bullish setup looks for a bearish gap that price closes above; a bearish setup looks for a bullish gap that price closes below. The gap being inverted may have formed before the trading candle opened, so long as it is no older than the extreme that started the retracement. Drawn at its own original location, which can sit well to the left.

MSS — a market structure shift. The indicator tracks swing highs and lows on the chart timeframe. When the last three swings form a high, low, high sequence and price then closes below that low, a line is drawn from the broken swing to the candle that closed through it. On a bullish setup the mirror applies. If the third swing also exceeded the first, taking out its level beforehand, a second line marks that swept level. An MSS is only marked if the level being broken is still short of the target, and only once per setup.

What Is Drawn
Stats Dashboard
The table counts how past setups on the selected higher timeframe resolved:
Please read this table for what it is. It is a count of what price did on the bars loaded in your chart. It is not a backtest and not a strategy report. No entry price, exit price, stop, commission, or slippage is assumed, because the indicator does not place trades. Outcomes still open — neither target reached nor gap invalidated — are excluded from all counts, so the figures move as those resolve. Past behaviour of a market does not indicate future behaviour.
Settings
Alerts
One alert fires when a zone is first tapped during the trading candle, with a message naming the timeframe and direction, for example 1h bullish FVG tapped. It fires at most once per setup. To use it, create an alert on the indicator and choose Any alert() function call as the condition.
Repainting
Historical bars are never restated. Specifically:
There is one deliberate removal, and it is worth stating plainly: a zone that price never trades into during the trading candle is deleted when that candle closes. This keeps the chart to setups that actually became live, but it does mean you will not see discarded gaps when scrolling back. The stats table counts them under "No setup".
The zone box, the target line and confirmation boxes extend to the right as the trading candle progresses. That is a drawing being lengthened, not a value being changed.
Limitations
Disclaimer
This script is for informational and educational purposes only. It is not financial advice and not a recommendation to buy or sell anything. Trading involves substantial risk of loss. Test any tool thoroughly and make your own decisions.
FVG Handoff looks for a fair value gap on a higher timeframe, then waits to see whether price returns to that gap on the very next higher timeframe candle. Throughout this description the three candles that form the gap are called the context candles, and the one after them is the trading candle.
The indicator is designed so that the whole setup can be visualised from the lower timeframe you intend to trade. The higher timeframe is read in the background and its structure is drawn onto your chart, so there is no need to switch timeframes to see where the gap sits or how the trading candle is developing. Any confirmation the indicator marks is one that occurred on your own chart timeframe, within the span of the trading candle.
The tool draws structure and context. It does not generate buy or sell signals, and it does not manage entries, exits, stops, or position size. Those decisions are left to the trader.
The Higher Timeframe Pattern
A fair value gap is a three candle pattern where the first and third context candles do not overlap.
- Bullish: the low of the third context candle is above the high of the first, and the middle one closes up.
- Bearish: the high of the third context candle is below the low of the first, and the middle one closes down.
The gap between the first and third context candles is the zone. It is drawn on your chart as a shaded box.
The target is the furthest extreme of the second and third context candles — the highest high on a bullish pattern, the lowest low on a bearish one. The second is the impulse candle and often overshoots the third, which is why both are considered rather than the third alone.
Why Only The Next Candle
Most fair value gap tools keep a gap on the chart indefinitely and mark it whenever price eventually returns, which can be days later. This indicator only considers the immediately following higher timeframe candle — the trading candle.
Everything happens within it:
- If price never trades into the zone during the trading candle, the setup is discarded and its drawings are removed from the chart.
- If price reaches the target before it reaches the zone, the setup is discarded — there is nowhere left for it to go.
- If price trades into the zone during the trading candle, the setup becomes active and the zone is shaded more strongly.
This is a deliberate narrowing, not an oversight. It selects for gaps that the market reacts to immediately rather than gaps that happen to be revisited much later.
Lower Timeframe Confirmations
Once the zone has been tapped, the indicator looks for a confirmation on your chart timeframe, within the trading candle. Each type fires at most once per setup, and each can be turned on or off independently.
FVG — a fair value gap in the same direction as the setup forming on the chart timeframe, in other words price leaving the higher timeframe zone with a gap of its own. Drawn as a box over the three candles that formed it.
IFVG — a gap in the opposite direction that price then closes back through, inverting it. A bullish setup looks for a bearish gap that price closes above; a bearish setup looks for a bullish gap that price closes below. The gap being inverted may have formed before the trading candle opened, so long as it is no older than the extreme that started the retracement. Drawn at its own original location, which can sit well to the left.
MSS — a market structure shift. The indicator tracks swing highs and lows on the chart timeframe. When the last three swings form a high, low, high sequence and price then closes below that low, a line is drawn from the broken swing to the candle that closed through it. On a bullish setup the mirror applies. If the third swing also exceeded the first, taking out its level beforehand, a second line marks that swept level. An MSS is only marked if the level being broken is still short of the target, and only once per setup.
What Is Drawn
- Zone — a grey box spanning the HTF FVG. Lightly shaded while untouched, more strongly shaded once price has traded into it.
- Target line — a dashed line from the bar that made the extreme, ending at the candle that reaches the target or at the end of the trading candle, whichever comes first.
- Confirmation boxes — FVG in blue, IFVG in cyan, each labelled and extended until candles clear them.
- MSS lines — a solid line for the broken swing and a dotted line for the swept level.
- Higher timeframe panel — the three context candles and the trading candle redrawn to the right of the live chart, with the gap marked across them and the target line running through. The trading candle updates live. This lets you see the higher timeframe structure without switching timeframes.
- Separators — a vertical line at the open of each higher timeframe candle.
- EMA — drawn only across the span of a setup rather than continuously.
Stats Dashboard
The table counts how past setups on the selected higher timeframe resolved:
- Tap to target — price traded into the zone during the trading candle, and later reached the target without a higher timeframe candle first closing through the far side of the gap.
- Tap to fail — price traded into the zone during the trading candle, but a higher timeframe candle closed through the far side of the gap before the target was reached.
- No setup — the zone was never tapped during the trading candle, or the target was taken before price returned.
- Hit rate — the first figure as a percentage of the first two.
Please read this table for what it is. It is a count of what price did on the bars loaded in your chart. It is not a backtest and not a strategy report. No entry price, exit price, stop, commission, or slippage is assumed, because the indicator does not place trades. Outcomes still open — neither target reached nor gap invalidated — are excluded from all counts, so the figures move as those resolve. Past behaviour of a market does not indicate future behaviour.
Settings
- Chart Theme — light or dark colour palette.
- Stats Dashboard — show or hide the table.
- Higher Timeframe — 15m, 1h, 4h, D, W or M.
- HTF Candle Separators — vertical line at each higher timeframe open.
- Show FVG / Show IFVG / Show MSS — confirmation types, independently toggled.
- Show EMA / EMA Length — optional EMA across the setup.
Alerts
One alert fires when a zone is first tapped during the trading candle, with a message naming the timeframe and direction, for example 1h bullish FVG tapped. It fires at most once per setup. To use it, create an alert on the indicator and choose Any alert() function call as the condition.
Repainting
Historical bars are never restated. Specifically:
- Higher timeframe candles are built by aggregating completed chart bars, so a pattern is only known once its third candle has closed. request.security() with lookahead is not used anywhere in the script.
- All detection runs on confirmed bars. A condition that appears mid-bar and is gone by the close never registers.
- Drawings are placed on the bar where the event actually occurred, even when the event only becomes knowable a bar or two later. Detection timing affects when a drawing appears, never where.
There is one deliberate removal, and it is worth stating plainly: a zone that price never trades into during the trading candle is deleted when that candle closes. This keeps the chart to setups that actually became live, but it does mean you will not see discarded gaps when scrolling back. The stats table counts them under "No setup".
The zone box, the target line and confirmation boxes extend to the right as the trading candle progresses. That is a drawing being lengthened, not a value being changed.
Limitations
- Only the next candle is considered. A gap that price returns to two or more candles later is ignored by design. If you want every gap tracked indefinitely, this is not the tool for that.
- On the higher timeframe itself, the trading candle is a single bar. Its open, high, low and close cannot say whether price tapped the zone before or after it reached the target. Lower timeframe confirmations, the target line and the stats table are therefore not shown when your chart timeframe equals the selected higher timeframe. Only the gap is drawn there.
- Above the higher timeframe, nothing is drawn. Select a chart timeframe lower than the higher timeframe setting.
- Swing detection for MSS uses a fixed strength of one bar either side. This is intentional, because the structure being measured sits inside a single higher timeframe candle, but it is sensitive and will pick up minor swings.
- A pivot needs one bar to confirm, so an MSS occurring on the last bar of the trading candle is detected a bar late. The line is still drawn at the correct candle.
- Drawing objects are capped by the platform. On very long histories the oldest drawings will drop off the chart.
- The stats table depends on how much history your plan loads, so the counts will differ between account types on the same instrument.
- This is an indicator, not a strategy. It offers no entries, exits, stop levels, position sizing, or risk management, and makes no claim about profitability.
Disclaimer
This script is for informational and educational purposes only. It is not financial advice and not a recommendation to buy or sell anything. Trading involves substantial risk of loss. Test any tool thoroughly and make your own decisions.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.