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
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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Settings | |||
| Show Regular FVG | true | bool | line 40 line 41 |
| Show Inverse FVG | true | bool | line 50 line 51 |
| Rfvg color (no label in the script) | color.new(color.blue, 50) | color | line 40 line 41 |
| Ifvg color (no label in the script) | color.new(color.red, 50) | color | line 50 line 51 |
| DisplacementLarger Displacement will require larger FVGs | 3 | int | atr_check |
| Display LimitThe maximum amount of FVGs and IFVGs to display | 10 | int | line 62 line 76 |
| Session (no label in the script)FVGs will only be saved if they are created within this time period | 0000-0000 | session | t |
| Rejections | |||
| Rejection StrengthLarger values will require larger fractals/swing pivots to justify as rejections | 1 | int | _rrj_bear _rrj_bull _irj_bear _irj_bull |
| Regular FVGShow rejections made within regular FVGs | false | bool | plotshape |
| Inverse FVGShow rejections made within inverse FVGs | false | bool | plotshape |
| Regular + Inverse FVGShow rejections made within both regular and inverse FVGs | true | bool | plotshape |
| Rrj color (no label in the script) | color.blue | color | plotshape |
| Irj color (no label in the script) | color.red | color | plotshape |
| Brj color (no label in the script) | color.black | color | plotshape |
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.
What it draws
| Output | Call | Value | By default | Line |
|---|---|---|---|---|
| plotshape | plotshape | show_rrj and reg_rj_bear[1] | Shown | 99 |
| plotshape | plotshape | show_rrj and reg_rj_bull[1] | Shown | 100 |
| plotshape | plotshape | show_irj and inv_rj_bear[1] | Shown | 101 |
| plotshape | plotshape | show_irj and inv_rj_bull[1] | Shown | 102 |
| plotshape | plotshape | show_brj and reg_rj_bear[1] and inv_rj_bear[1] | Shown | 103 |
| plotshape | plotshape | show_brj and reg_rj_bull[1] and inv_rj_bull[1] | Shown | 104 |
Does it repaint?
Yes
The live replay did not match history.
- 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
VerifiedNothing 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.
⋯// © tradeforopp-//@version=5+//@version=6indicator("Inverse FVG with Rejections [TFO]", "Inverse FVG [TFO]", true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 101 ms | With a workaround 1,000 bars in 313 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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 --------------------------------------------------