Strategy · Pine Script v6 · On the chart

VCP probe 02 fvg zones

by pineforge-4pass· code credited to PineForge contributors 2026

This strategy detects Fair Value Gaps on the price chart using 3-bar candle imbalances filtered by ATR.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code96
Settings0inputs
LicenceApache-2.0
Last update5 days ago23 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

96 lines of Pine Script v6 from validation/composite-vcp-fvg-active-zones-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// VCP probe 02 — Fair Value Gap detection + active-zone iteration
//
// Purpose: isolate the FVG half of the VCP integration probe family. That
// family defines an FVG as a 3-bar imbalance gated by an ATR-fraction
// minimum size, then keeps every active gap in a parallel
// ``array<float>`` / ``array<bool>`` triple (tops / bottoms / bullish
// flag) capped at 30. On every bar it iterates ALL active zones to
// compute ``inBullFVG`` / ``inBearFVG`` for the current candle. That zone
// iteration is what gates VCP's structure-confluence bonus (``+1`` to
// structScore when in zone + matching structureDirection).
//
// This probe replicates the FVG state machine VERBATIM — same gap
// conditions, same ATR multiplier (0.3), same array<float> retention,
// same per-bar containment loop — and routes a trivial entry/exit
// through it. Any TV/engine drift here is attributable to FVG state
// management (push/shift cap, per-bar containment loop, atr-mult
// minimum size) and NOT to the rest of VCP's stack.
//
// Trade shape: long-only, pyramiding=1. Enter long when the current
// bar's HL range overlaps an active BULL FVG (i.e. ``inBullFVG``
// becomes true while flat). Close the long when an active BEAR FVG
// is touched.
//
// TV setup: 15m chart, ETH-USDT-USDT, same window as
// data/ohlcv_ETH-USDT-USDT_15m.csv. Export the trade list to trades.csv
// in this folder.
//@version=6
strategy("VCP probe 02 - fvg zones", shorttitle="VCP_p02",
     overlay=true, initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0,
     slippage=0, default_qty_type=strategy.fixed, default_qty_value=1,
     pyramiding=1, process_orders_on_close=false,
     max_boxes_count=300)

// ---- ATR (literal length 14, matching VCP line 187) ----------------
float atrVal = ta.atr(14)

// ---- FVG detection — IDENTICAL conditions to VCP -------------------
bool bullFVG = low > high[2] and close[1] > open[1]
bool bearFVG = high < low[2] and close[1] < open[1]

float minFVGSize = atrVal * 0.3

// ---- FVG storage (mirror of VCP's parallel arrays) -----------------
var array<float> fvgTops    = array.new<float>()
var array<float> fvgBottoms = array.new<float>()
var array<bool>  fvgBullish = array.new<bool>()

float fvgTop    = na
float fvgBottom = na

if bullFVG and (low - high[2]) >= minFVGSize
    fvgTop    := low
    fvgBottom := high[2]
    array.push(fvgTops, fvgTop)
    array.push(fvgBottoms, fvgBottom)
    array.push(fvgBullish, true)

if bearFVG and (low[2] - high) >= minFVGSize
    fvgTop    := low[2]
    fvgBottom := high
    array.push(fvgTops, fvgTop)
    array.push(fvgBottoms, fvgBottom)
    array.push(fvgBullish, false)

while array.size(fvgTops) > 30
    array.shift(fvgTops)
    array.shift(fvgBottoms)
    array.shift(fvgBullish)

// ---- per-bar containment loop — IDENTICAL pattern to VCP -----------
bool inBullFVG = false
bool inBearFVG = false

if array.size(fvgTops) > 0
    for i = 0 to array.size(fvgTops) - 1
        float fTop    = array.get(fvgTops, i)
        float fBottom = array.get(fvgBottoms, i)
        bool  isBull  = array.get(fvgBullish, i)

        if low <= fTop and high >= fBottom
            if isBull
                inBullFVG := true
            else
                inBearFVG := true

// ---- trivial entry / exit ------------------------------------------
if inBullFVG and strategy.position_size == 0
    strategy.entry("L", strategy.long, qty=1, comment="bull-fvg touch")

if inBearFVG and strategy.position_size > 0
    strategy.close("L", comment="bear-fvg touch exit")

Overview

VCP probe 02 fvg zones maintains a capped array of active FVG zones with their tops, bottoms, and bullish flags. Long entries occur when the current bar overlaps an active bullish FVG. Exits trigger on overlap with an active bearish FVG. The script runs on the price chart only with fixed position sizing and pyramiding of 1. No inputs exist to adjust parameters. It draws zones directly on price bars without a separate pane and lacks any stop-loss protection.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Candlestick patterns, Mean reversion

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

1 stars

This Pine Script strategy detects ICT smart money concepts including order test zones, fair value gaps, and wicks on BTC and XAUUSD price charts. It calculates swings using pivot high and low. Signals enter long or short when the order test zone is hit with su

Strategy v5 SMC / ICT / price actionCandlestick patterns
Updated 6 months ago · None stated GitHub repository of ICT v4-weinkya BTC Improved
330 stars

Exceeded Candle [Alorse] is a mean-reversion strategy that identifies candlestick engulfing patterns combined with Bollinger Bands filters. It enters a long position when a green candle surpasses the body of the previous red candle while price is below the mid

Strategy v4 Mean reversionCandlestick patterns
Updated 2 months ago · None stated GitHub repository of Exceeded candle [Alorse]
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy

STRG One Bar Pursuit

by harryguiacorn
219 stars

The STRG One Bar Pursuit strategy identifies single-bar momentum reversals by monitoring shifts between bullish and bearish candlesticks starting from the year 2024. It enters a long position when a bullish candle follows a bearish candle and enters a short po

Strategy v5 Candlestick patternsMean reversion
Updated 1 year ago · None stated GitHub repository of STRG One Bar Pursuit

A Strategy for Leledec

by hasnocool
106 stars

This Pine Script strategy identifies major and minor Leledec exhaustion bars by tracking consecutive price bar comparisons against past closes and checking local extremes over set lookback lengths. It overlays visual markers directly on the price chart for det

Strategy v4 Mean reversionCandlestick patterns
Updated 2 years ago · GPL-3.0 GitHub repository of A Strategy for Leledec

FVG RSI Strategy (Optimized)

by skywalker0803r
42 stars

This strategy plots on the price chart and trades fair value gaps filtered by RSI and two EMAs. It opens a long when a bullish gap, a rising candle, RSI below the oversold level, and price under both EMAs align, and a short on the opposite conditions. Each tra

Strategy v5 SMC / ICT / price actionOscillators & momentum
Updated 2 months ago · None stated GitHub repository of FVG RSI Strategy (Optimized)

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers