Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Indicator

Inverse FVG with Rejections [TFO]

A Pine Script v5 indicator with no technical-analysis calculation. It draws 6 marker series in its own pane. 14 settings; defaults include Displacement 3, Display Limit 10 and Session 0000-0000.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Inverse FVG with Rejections [TFO] repaint?
Yes
In a live replay, it did not match history on 7 of 300 bars.
How many settings does Inverse FVG with Rejections [TFO] have?
14
Defaults include Show Regular FVG true, Show Inverse FVG true, Displacement 3.
Does Inverse FVG with Rejections [TFO] run in Pine Script v6?
Yes
Every plotted value identical on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Inverse FVG with Rejections [TFO] draw on the price chart?
No
It draws in its own pane below the price.
Does Inverse FVG with Rejections [TFO] run in Zeal Terminal?
Yes
It compiles in 101 ms and runs 1,000 bars in 313 ms, in the browser.

BTCUSDT · 1D · default settings

  • Shape
  • Shape
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Lines and shading are what the script draws. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

The value of each line the script plots, on the last of 1,000 bars, with the default settings.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Note

    1 setting has no label

    In the settings dialog session (line 13) shows an empty name. The labels on this page come from the variable names.

  • Note

    No alerts

    The script declares no alertcondition, so you can't be notified when its state changes.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Settings
Show Regular FVGtrueboolline 40 line 41
Show Inverse FVGtrueboolline 50 line 51
Rfvg color (no label in the script)color.new(color.blue, 50)colorline 40 line 41
Ifvg color (no label in the script)color.new(color.red, 50)colorline 50 line 51
DisplacementLarger Displacement will require larger FVGs3intatr_check
Display LimitThe maximum amount of FVGs and IFVGs to display10intline 62 line 76
Session (no label in the script)FVGs will only be saved if they are created within this time period0000-0000sessiont
Rejections
Rejection StrengthLarger values will require larger fractals/swing pivots to justify as rejections1int_rrj_bear _rrj_bull _irj_bear _irj_bull
Regular FVGShow rejections made within regular FVGsfalseboolplotshape
Inverse FVGShow rejections made within inverse FVGsfalseboolplotshape
Regular + Inverse FVGShow rejections made within both regular and inverse FVGstrueboolplotshape
Rrj color (no label in the script)color.bluecolorplotshape
Irj color (no label in the script)color.redcolorplotshape
Brj color (no label in the script)color.blackcolorplotshape

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

Signal flow

How price data and settings reach what is drawn. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

lowlowprice datahighhighprice datasessionSessionsetting · 0000-0000openopenprice dataclosecloseprice datadisp_xDisplacementsetting · 3psRejection Strengthsetting · 1fvg, fvg_lenfvg · fvg_len2 valuestoptopvaluebottombottomvaluettconditionbullbullconditionatr_checkatr_checkconditionremove_bull, remove_bear, remove_inv_bear, remove_inv_bullremove_bull · remove_be…4 conditions_rrj_bear, _irj_bear_rrj_bear · _irj_bear2 conditions_rrj_bull, _irj_bull_rrj_bull · _irj_bull2 conditionsplotshape:99plotshapeplotshapeplotshape:100plotshapeplotshapeplotshape:101plotshapeplotshapeplotshape:102plotshapeplotshapeplotshape:103plotshapeplotshapeplotshape:104plotshapeplotshape

What it draws

OutputCallValueBy defaultLine
plotshapeplotshapeshow_rrj and reg_rj_bear[1]Shown99
plotshapeplotshapeshow_rrj and reg_rj_bull[1]Shown100
plotshapeplotshapeshow_irj and inv_rj_bear[1]Shown101
plotshapeplotshapeshow_irj and inv_rj_bull[1]Shown102
plotshapeplotshapeshow_brj and reg_rj_bear[1] and inv_rj_bear[1]Shown103
plotshapeplotshapeshow_brj and reg_rj_bull[1] and inv_rj_bull[1]Shown104

Does it repaint?

Yes

The live replay did not match history.

293/300bars identical at close when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. On 0 of them the colour changed while the bar was forming before it settled.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip or realtime-only state. Values move while a bar forms and settle when it closes, as every indicator's do.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets, each the most recent 1,000 bars.

Market
BTCUSDT 1D
BTCUSDT 4h
ETHUSDT 1D
ETHUSDT 4h
SOLUSDT 1D
SOLUSDT 4h
BNBUSDT 1D
BNBUSDT 4h

Each line's value on the last bar.

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Yes

Every plotted value identical on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © tradeforopp-//@version=5+//@version=6indicator("Inverse FVG with Rejections [TFO]", "Inverse FVG [TFO]", true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 101 msWith a workaround 1,000 bars in 313 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © tradeforopp//@version=5indicator("Inverse FVG with Rejections [TFO]", "Inverse FVG [TFO]", true)// -------------------------------------------------- Inputs --------------------------------------------------var g_SET = "Settings"show_rfvg = input.bool(true, "Show Regular FVG", inline = "RFVG", group = g_SET)show_ifvg = input.bool(true, "Show Inverse FVG", inline = "IFVG", group = g_SET)rfvg_color = input.color(color.new(color.blue, 50), "", inline = "RFVG", group = g_SET)ifvg_color = input.color(color.new(color.red, 50), "", inline = "IFVG", group = g_SET)disp_x = input.int(3, "Displacement", 1, 10, tooltip = "Larger Displacement will require larger FVGs", group = g_SET)disp_limit = input.int(10, "Display Limit", 1, 50, tooltip = "The maximum amount of FVGs and IFVGs to display", group = g_SET)session = input.session("0000-0000", "Session", tooltip = "FVGs will only be saved if they are created within this time period", group = g_SET)var g_RJ = "Rejections"ps = input.int(1, "Rejection Strength", tooltip = "Larger values will require larger fractals/swing pivots to justify as rejections", group = g_RJ) show_rrj = input.bool(false, "Regular FVG", inline = "RRJ", tooltip = "Show rejections made within regular FVGs", group = g_RJ)show_irj = input.bool(false, "Inverse FVG", inline = "IRJ", tooltip = "Show rejections made within inverse FVGs", group = g_RJ)show_brj = input.bool(true, "Regular + Inverse FVG", inline = "BRJ", tooltip = "Show rejections made within both regular and inverse FVGs", group = g_RJ)rrj_color = input.color(color.blue, "", inline = "RRJ", group = g_RJ)irj_color = input.color(color.red, "", inline = "IRJ", group = g_RJ)brj_color = input.color(color.black, "", inline = "BRJ", group = g_RJ)// -------------------------------------------------- Inputs --------------------------------------------------// -------------------------------------------------- Logic --------------------------------------------------t = not na(time("", session, "America/New_York"))bull = close[2] > open[2]fvg = bull ? (high[3] < low[1] and low[2] <= high[3] and high[2] >= low[1]) : (low[3] > high[1] and low[2] <= high[1] and low[3] <= high[2])fvg_len = bull ? low[1] - high[3] : low[3] - high[1]atr_check = fvg_len > ta.atr(50) * disp_x / 10var reg_fvg = array.new_box()var reg_fvg_ce = array.new_line()var reg_fvg_side = array.new_string()var inv_fvg = array.new_box()var inv_fvg_ce = array.new_line()var inv_fvg_side = array.new_string()solid_color(color x) =>    color.new(x, 0)if t[2] and fvg and atr_check    top = bull ? low[1] : low[3]    bottom = bull ? high[3] : high[1]    reg_fvg.unshift(box.new(time[2], top, time, bottom, xloc = xloc.bar_time, extend = extend.right, bgcolor = show_rfvg ? rfvg_color : na, border_color = na))    reg_fvg_ce.unshift(line.new(time[2], math.avg(top, bottom), time, math.avg(top, bottom), xloc = xloc.bar_time, extend = extend.right, color = show_rfvg ? solid_color(rfvg_color) : na, style = line.style_dashed))    reg_fvg_side.unshift(bull ? 'bull' : 'bear')if reg_fvg.size() > 0    for i = reg_fvg.size() - 1 to 0        remove_bull = reg_fvg_side.get(i) == 'bull' and close[1] < reg_fvg.get(i).get_bottom()        remove_bear = reg_fvg_side.get(i) == 'bear' and close[1] > reg_fvg.get(i).get_top()        if remove_bull or remove_bear            inv_fvg.unshift(box.copy(reg_fvg.get(i)))            inv_fvg_ce.unshift(line.copy(reg_fvg_ce.get(i)))            inv_fvg.get(0).set_bgcolor(show_ifvg ? ifvg_color : na)            inv_fvg_ce.get(0).set_color(show_ifvg ? solid_color(ifvg_color) : na)            box.delete(reg_fvg.get(i))            line.delete(reg_fvg_ce.get(i))            reg_fvg.remove(i)            reg_fvg_ce.remove(i)            reg_fvg_side.remove(i)                        if remove_bear                inv_fvg_side.unshift('inv bear')            else if remove_bull                inv_fvg_side.unshift('inv bull')    if reg_fvg.size() > disp_limit        box.delete(reg_fvg.pop())        line.delete(reg_fvg_ce.pop())        reg_fvg_side.pop()if inv_fvg.size() > 0    for i = inv_fvg.size() - 1 to 0        remove_inv_bear = inv_fvg_side.get(i) == 'inv bear' and close[1] < inv_fvg.get(i).get_bottom()        remove_inv_bull = inv_fvg_side.get(i) == 'inv bull' and close[1] > inv_fvg.get(i).get_top()        if remove_inv_bear or remove_inv_bull            box.delete(inv_fvg.get(i))            line.delete(inv_fvg_ce.get(i))            inv_fvg.remove(i)            inv_fvg_ce.remove(i)            inv_fvg_side.remove(i)    if inv_fvg.size() > disp_limit        box.delete(inv_fvg.pop())        line.delete(inv_fvg_ce.pop())        inv_fvg_side.pop()reg_rj_bear = falsereg_rj_bull = falseinv_rj_bear = falseinv_rj_bull = falseif math.min(reg_fvg.size(), inv_fvg.size()) > 0    for i = 0 to reg_fvg.size() - 1        _rrj_bear = ta.pivothigh(high, ps, ps) and high[ps] >= reg_fvg.get(i).get_bottom() and high[ps] <= reg_fvg.get(i).get_top()        _rrj_bull = ta.pivotlow(low, ps, ps) and low[ps] >= reg_fvg.get(i).get_bottom() and low[ps] <= reg_fvg.get(i).get_top()        if _rrj_bear            reg_rj_bear := true        if _rrj_bull            reg_rj_bull := true    for i = 0 to inv_fvg.size() - 1        _irj_bear = ta.pivothigh(high, ps, ps) and high[ps] >= inv_fvg.get(i).get_bottom() and high[ps] <= inv_fvg.get(i).get_top()        _irj_bull = ta.pivotlow(low, ps, ps) and low[ps] >= inv_fvg.get(i).get_bottom() and low[ps] <= inv_fvg.get(i).get_top()        if _irj_bear            inv_rj_bear := true        if _irj_bull            inv_rj_bull := trueplotshape(show_rrj and reg_rj_bear[1], color = rrj_color, size = size.small, location = location.abovebar, style = shape.triangledown)plotshape(show_rrj and reg_rj_bull[1], color = rrj_color, size = size.small, location = location.belowbar, style = shape.triangleup)plotshape(show_irj and inv_rj_bear[1], color = irj_color, size = size.small, location = location.abovebar, style = shape.triangledown)plotshape(show_irj and inv_rj_bull[1], color = irj_color, size = size.small, location = location.belowbar, style = shape.triangleup)plotshape(show_brj and reg_rj_bear[1] and inv_rj_bear[1], color = brj_color, size = size.small, location = location.abovebar, style = shape.triangledown)plotshape(show_brj and reg_rj_bull[1] and inv_rj_bull[1], color = brj_color, size = size.small, location = location.belowbar, style = shape.triangleup)// -------------------------------------------------- Logic --------------------------------------------------