OPEN-SOURCE SCRIPT

2x FVG + BOS/CHoCH + EMA + RSI Gradient + PVSRA

892
OVERVIEW

2x FVG Structure and PVSRA Footprint Toolkit is an intraday market-analysis indicator designed to combine several different layers of market information into one structured workflow:

1. Trend and directional context using EMA 50 and EMA 200
2. Market structure using BOS and CHoCH
3. Price imbalance using Fair Value Gaps
4. Detection of two distinct same-direction FVG structures
5. Volume-based PVSRA / Vector Candle classification
6. Volume Footprint Buy/Sell dominance
7. Optional RSI-based candle coloring
8. Alerts for selected structural, EMA, FVG and PVSRA events

The purpose of combining these modules is not to produce a standalone automatic buy or sell signal.

Instead, the indicator is intended to help traders evaluate several independent pieces of market information on the same chart and determine whether price structure, imbalance, volume activity and directional participation are supporting the same market scenario.

The indicator does not place trades, calculate position size, define risk, or guarantee future price direction.


WHY THESE MODULES ARE COMBINED

This indicator is not intended to be a collection of unrelated indicators.

Each module has a specific role in the analysis process.

EMA 50 and EMA 200 provide broader directional context.

BOS and CHoCH identify changes or continuation in confirmed market structure.

Fair Value Gaps identify three-candle price inefficiencies.

The 2x FVG module identifies situations where two separate same-direction imbalance structures occur within a configurable number of bars.

PVSRA highlights candles with abnormal volume or volume-spread activity.

Volume Footprint statistics provide additional information about the distribution of classified Buy and Sell volume inside selected candles.

The intended workflow is therefore:

CONTEXT
→ STRUCTURE
→ IMBALANCE
→ VOLUME
→ FOOTPRINT CONFIRMATION

A trader can use each layer independently, but the main purpose of the indicator is to provide contextual confirmation between different types of market information.


EMA 50 AND EMA 200

The indicator calculates two Exponential Moving Averages:

Fast EMA:
Default length = 50

Slow EMA:
Default length = 200

Both lengths, colors and line widths can be changed in the settings.

The EMA module provides a simple representation of medium-term and longer-term price direction.

A bullish EMA cross occurs when the Fast EMA crosses above the Slow EMA.

A bearish EMA cross occurs when the Fast EMA crosses below the Slow EMA.

The script can display small visual markers when these crosses occur and can generate corresponding alert conditions.

The EMA module should be treated as market context rather than as an independent entry system.

For example, a trader may choose to give more weight to bullish structural setups while the Fast EMA is above the Slow EMA and more weight to bearish setups while the opposite condition exists.

This is only one possible interpretation and is not enforced by the indicator.


MARKET STRUCTURE: SWING HIGH AND SWING LOW

Market structure is calculated using confirmed pivot highs and pivot lows.

The Swing Length setting determines how many bars are required on each side of a potential swing.

With the default Swing Length of 5, a pivot requires five bars to the left and five bars to the right before it can be confirmed.

This has an important consequence:

A swing point cannot be known at the moment the original high or low occurs.

It becomes confirmed only after the required number of right-side bars exists.

Therefore, historical swing locations must not be interpreted as signals that were available at the original swing bar.

The indicator uses these confirmed swings as reference levels for BOS and CHoCH detection.


BOS — BREAK OF STRUCTURE

A Break of Structure identifies a break of a previously confirmed swing level in the current structural direction.

Depending on the Structure Break Confirmation setting, a break can be confirmed using:

Close
or
Wick

When Close is selected, price must close beyond the swing level.

When Wick is selected, the high or low of the candle can confirm the break.

A bullish BOS represents a confirmed break above a relevant swing high while the internal structural direction is already bullish or has not previously established a bearish reversal condition.

A bearish BOS represents the corresponding break below a relevant swing low.

BOS should generally be interpreted as a structural continuation event rather than an automatic trade signal.


CHOCH — CHANGE OF CHARACTER

CHoCH is used to identify a possible change in structural direction.

A bullish CHoCH occurs when price breaks a confirmed swing high while the previously tracked structure was bearish.

A bearish CHoCH occurs when price breaks a confirmed swing low while the previously tracked structure was bullish.

This can help identify potential transitions between bearish and bullish structure.

A CHoCH does not guarantee a reversal.

Markets frequently produce temporary structural breaks before continuing in the previous direction.

For this reason, CHoCH is intended to be evaluated together with other information such as FVGs, EMA context, PVSRA activity and Footprint dominance.


IMPORTANT STRUCTURE DISPLAY BEHAVIOR

When a BOS or CHoCH occurs, the horizontal structure line begins at the historical swing that was broken and ends at the bar that confirmed the break.

The visual line therefore extends backward to the location of the swing.

This does NOT mean the BOS or CHoCH signal was known at the swing bar.

The actual structural event is confirmed only when the later candle breaks the swing according to the selected Close or Wick confirmation method.

This distinction is important when visually reviewing historical charts.


FAIR VALUE GAP — FVG

The indicator detects traditional three-candle Fair Value Gaps.

A Bullish FVG is detected when:

Current Low > High from two bars earlier

A Bearish FVG is detected when:

Current High < Low from two bars earlier

This represents a price range that was not overlapped by the first and third candles of the three-candle sequence.

The FVG is created only on a confirmed bar.

Users can optionally apply a minimum FVG size filter.

The minimum size can be expressed in:

Points
or
Ticks

This can be useful for reducing very small imbalances that may have limited analytical value on a particular instrument.

The appropriate minimum FVG size depends on the instrument, volatility and timeframe.

There is no universal value that works for every market.


FVG VISIBILITY

The indicator allows users to display:

All available FVGs

or

Only FVGs from the most recent configured number of hours.

The default historical window is 24 hours.

A maximum number of FVG objects is also enforced to protect chart performance and TradingView object limits.

IMPORTANT:

The current implementation does not automatically remove an FVG simply because price later trades through or mitigates the zone.

The displayed FVG therefore represents the historical detection of the imbalance, not necessarily an active or unmitigated trading zone.


2x FVG LOGIC

The 2x FVG module is more selective than simply counting any two Fair Value Gaps.

The script tracks FVGs of the same direction occurring within the configurable Max Bars Between FVG setting.

The default value is 5 bars.

If a new same-direction FVG overlaps the currently tracked FVG cluster, the indicator treats the gaps as part of the same broader imbalance structure.

The cluster boundaries are expanded when necessary.

A 2x FVG event is generated when another same-direction FVG appears within the allowed bar window but forms a separate, non-overlapping imbalance rather than simply extending the existing cluster.

Therefore:

Two overlapping bullish FVGs are not necessarily treated as a completed 2x Bullish FVG signal.

Two distinct bullish FVG structures occurring close together can generate the bullish 2x marker.

The same logic applies in the bearish direction.

When an opposite-direction FVG occurs, the previous same-direction cluster is reset.

This design attempts to distinguish between one extended imbalance and two separate displacement events.


HOW TO INTERPRET 2x FVG

A 2x FVG should not automatically be interpreted as an entry.

It indicates that price has created multiple distinct inefficiencies in the same direction over a relatively short sequence of candles.

For example:

Bullish market structure
+
price above the broader EMA context
+
bullish BOS
+
two separate bullish FVGs
+
strong bullish PVSRA activity

provides more contextual information than a single FVG alone.

However, the indicator does not assign a statistical probability of success to such a configuration.

Users should test the behavior on the specific instrument and timeframe they trade.


PVSRA / VECTOR CANDLES

The PVSRA module classifies candles according to volume and candle spread.

The default volume lookback period is 10 bars.

The script calculates the average volume over this lookback period.

The default Above Average threshold is:

150% of average volume

The default Climax threshold is:

200% of average volume

A candle can also qualify as a Climax candle through the Volume x Spread calculation.

Volume x Spread is calculated as:

Volume × (High - Low)

The script compares this value with the highest Volume x Spread value over the configured PVSRA lookback.

This allows unusually large volume combined with a wide candle range to be identified even when the simple volume threshold alone may not fully describe the event.


PVSRA CANDLE COLORS

By default, the PVSRA candle categories are displayed as:

Green:
Bullish 200% / Climax candle

Red:
Bearish 200% / Climax candle

Blue:
Bullish 150% Above Average candle

Purple:
Bearish 150% Above Average candle

Light Gray:
Regular bullish candle

Dark Gray:
Regular bearish candle

All colors can be modified by the user.

The bullish or bearish classification of the candle itself is determined by comparing its Open and Close.

A bullish candle has:

Close > Open

A bearish candle has:

Close <= Open


PVSRA SOURCE SYMBOL

By default, PVSRA calculations use the current chart symbol.

An optional Override PVSRA Source Symbol setting is available.

This allows the volume calculations to use another symbol or data feed.

This feature should be used carefully.

If the PVSRA source symbol is different from the chart symbol, the volume information no longer represents exactly the same instrument displayed on the chart.

The user is responsible for selecting a logically appropriate source.


WHAT A PVSRA CLIMAX MEANS

A Climax candle indicates unusually high activity relative to recent bars.

It does NOT automatically indicate reversal.

For example, a bullish Climax candle can represent:

Strong continuation buying

Aggressive participation during a breakout

Buying absorption

Late participation near the end of a move

or increased activity around an important level.

Context is therefore essential.

A high-volume candle is evidence of increased activity, not proof of the next market direction.


VOLUME FOOTPRINT BUY/SELL DOMINANCE

The Footprint module uses TradingView's volume footprint data.

For selected candles, the script retrieves:

Total Volume

Buy Volume

Sell Volume

Volume Delta

The script then calculates:

Buy % = Buy Volume / Total Volume × 100

Sell % = Sell Volume / Total Volume × 100

Delta % = Volume Delta / Total Volume × 100

where:

Volume Delta = Buy Volume - Sell Volume


IMPORTANT INFORMATION ABOUT BUY AND SELL VOLUME

The words BUY and SELL in the Footprint module refer to TradingView's volume footprint classification.

TradingView classifies lower-timeframe volume according to the direction of intrabar price movement.

This should not be interpreted as direct access to every participant's intentions, resting limit orders, or the complete exchange order book.

The indicator does NOT display DOM resting liquidity.

It does NOT show pending limit orders.

It does NOT identify how many individual traders are buying or selling.

It displays TradingView's calculated Buy and Sell footprint volume categories.

This distinction is important when interpreting the values.


FOOTPRINT DOMINANCE

The indicator compares Buy % and Sell %.

If the difference between the two sides is smaller than or equal to the Neutral Threshold, the candle is classified as NEUTRAL.

The default Neutral Threshold is 5 percentage points.

For example:

BUY = 52%
SELL = 48%

Difference = 4 percentage points

With a 5% Neutral Threshold, this candle is considered neutral.

Another example:

BUY = 67%
SELL = 33%

Difference = 34 percentage points

This candle is classified as BUY dominance.

The same logic applies to SELL dominance.


FOOTPRINT BUBBLES

Footprint information is displayed using bubbles near selected candles.

BUY dominance is displayed below the candle.

SELL dominance is displayed above the candle.

Neutral conditions are also displayed above the candle.

The bubble can contain:

BUY or SELL classification

Buy or Sell percentage

Volume Delta percentage

A detailed tooltip can additionally display:

Buy Volume

Sell Volume

Total Volume

Buy %

Sell %

Absolute Delta

Delta %

Dominance classification

Difference between Buy and Sell percentages


DYNAMIC BUBBLE SIZE

When Dynamic Bubble Size is enabled, stronger Buy/Sell differences can produce larger bubbles.

The bubble size is therefore a visual representation of the magnitude of the Buy/Sell dominance difference.

It should not be interpreted as a prediction of future price movement.

The script also uses a simple anti-collision system that assigns nearby bubbles to different visual lanes to reduce overlap.


FOOTPRINT VISIBILITY FILTER

Users can choose which candles receive Footprint bubbles.

Available modes are:

200% Climax only

150% + 200%

All candles

The default mode is 200% Climax only.

This is intentional.

Displaying Footprint statistics only around unusually active PVSRA candles can reduce visual noise and focuses the Footprint module on bars where volume participation is already elevated.


FOOTPRINT HISTORY

The indicator includes an option to limit Footprint bubble history to approximately the most recent hour.

This reduces chart clutter and helps manage the amount of footprint data used by the script.

The current implementation also restricts footprint calculations to a limited number of recent bars for memory efficiency.

As a result, the Footprint component is primarily intended as a recent intraday analysis tool rather than a long-term historical footprint database.

The availability and precision of Footprint data can also depend on the symbol, timeframe, available market data and TradingView account/data access.


FOOTPRINT ROW SIZE

Ticks Per Footprint Row controls the aggregation size used in the footprint request.

However, this indicator currently uses the overall Buy Volume, Sell Volume, Total Volume and Delta of each requested footprint.

It does not display every individual footprint price row.

It therefore should not be confused with a complete Footprint chart showing bid/ask-style information at every individual price level.


RSI CANDLE GRADIENT

The indicator also includes an optional RSI candle-coloring mode.

The default RSI length is 14.

The gradient transitions through several ranges:

Very low RSI
→ green

Lower RSI
→ green/yellow

Mid-range RSI
→ yellow/orange

Higher RSI
→ red

Extreme high RSI
→ dark red

The default Oversold and Overbought reference values are 30 and 70.

This module is designed primarily as an alternative momentum visualization.

IMPORTANT:

PVSRA candle coloring has priority over RSI candle coloring.

If PVSRA and RSI Gradient are both enabled, PVSRA colors are displayed.

To view the RSI candle gradient directly, disable PVSRA candle coloring.


ALERTS

The indicator provides alert conditions for:

2x Bullish FVG

2x Bearish FVG

Any 2x FVG

Bullish BOS

Bearish BOS

Any BOS

Bullish CHoCH

Bearish CHoCH

Any CHoCH

Any Structure Break

Bullish EMA Cross

Bearish EMA Cross

Any EMA Cross

Bullish PVSRA Climax candle

Bearish PVSRA Climax candle

Any PVSRA Climax candle

Master "Any Signal" condition

The script also includes a repeating alert engine using alert() calls.

Signals are evaluated using confirmed bars.

This means alerts are intended to trigger after the relevant candle has closed rather than continuously changing during the still-forming candle.

The current Footprint bubble itself is not included as a separate alert condition.


PRACTICAL WORKFLOW

One possible way to use the indicator is to begin with directional context.

First evaluate the position and relationship of EMA 50 and EMA 200.

Then evaluate the most recent confirmed BOS or CHoCH.

Next examine whether the displacement created one or more Fair Value Gaps.

A 2x FVG can indicate that multiple separate price inefficiencies have formed in the same direction.

PVSRA can then be used to determine whether the move occurred with unusually high volume or Volume x Spread activity.

Finally, the Footprint bubble can provide additional information about TradingView-classified Buy/Sell volume dominance inside the selected high-activity candle.

This creates a multi-layer confirmation process rather than relying on one isolated indicator.


EXAMPLE OF BULLISH CONFLUENCE

A trader may observe:

EMA context favoring the upside

Bullish BOS or bullish CHoCH

Bullish FVG structure

Bullish 2x FVG

Bullish PVSRA Climax candle

BUY-dominant Footprint statistics

This combination may justify further investigation of a bullish scenario.

It does NOT mean a long trade must be taken.

The same concept can be mirrored for bearish conditions.


DIVERGENCE BETWEEN PRICE AND FOOTPRINT

The Footprint module may also be useful when its information disagrees with the candle direction.

For example, price may close bullish while the Footprint statistics show stronger Sell classification.

Likewise, a bearish candle may contain strong classified Buy volume.

Such situations can indicate more complex interaction between price movement and volume participation.

They can be worth observing around:

previous highs or lows

liquidity areas

major support or resistance

BOS or CHoCH levels

FVG boundaries

session extremes

However, these relationships are contextual observations and are not automatically classified by this version of the indicator as absorption or reversal signals.


TIMEFRAMES AND MARKETS

The indicator is primarily designed for intraday use.

It can technically operate on multiple standard chart timeframes, but the meaning of each component changes with timeframe and market structure.

Short timeframes generate more structural events and more FVGs, but also more noise.

Higher timeframes produce fewer signals and generally larger structural zones.

Users should adjust:

Swing Length

Minimum FVG Size

Maximum Bars Between FVGs

PVSRA thresholds

Footprint settings

according to the volatility and tick size of the instrument being analyzed.

The default settings should be treated as starting values rather than universally optimized parameters.

Volume-dependent modules are most meaningful on markets where reliable volume data is available.


STANDARD CANDLESTICK CHARTS RECOMMENDED

The indicator is designed for use with standard time-based candlestick charts.

Using synthetic chart types such as:

Heikin Ashi

Renko

Kagi

Point & Figure

Range

or Line Break

can change the relationship between displayed OHLC values and actual market prices.

For structural or signal-based analysis, standard candlestick charts are recommended.


REPAINTING, CONFIRMATION AND HISTORICAL DISPLAY

The script intentionally uses confirmed candles for FVG, structure, EMA-cross and PVSRA signal events.

The PVSRA security request uses lookahead disabled.

However, users should understand the behavior of confirmed pivots.

A pivot high or pivot low requires future right-side bars before it becomes confirmed.

The structure line is then drawn starting from the historical pivot.

Therefore, the historical location of a swing does not mean the swing was known in real time at that original candle.

Likewise, a BOS/CHoCH line visually beginning at a previous swing does not mean the structure break occurred there.

The actual BOS or CHoCH event occurs only on the later bar that confirms the break.

This is normal pivot-based structure behavior and should be considered when reviewing historical charts.


LIMITATIONS

This indicator does not predict future market direction.

It does not provide guaranteed entries or exits.

It does not calculate Stop Loss or Take Profit levels.

It does not calculate risk or position size.

It does not execute trades.

FVG zones are not automatically removed after mitigation.

BOS and CHoCH depend on confirmed swing pivots and therefore include structural confirmation delay.

PVSRA identifies unusual volume activity but cannot determine the intention of market participants.

Footprint BUY and SELL statistics are based on TradingView's footprint volume classification and should not be confused with direct DOM order-book liquidity.

The Footprint module currently uses bar-level total Buy/Sell statistics rather than displaying the complete footprint ladder at every price level.

The availability and granularity of Footprint data depend on TradingView's available lower-timeframe data and market-data access.

Historical results should not be interpreted as evidence of future performance.


INTENDED USE

This indicator is intended as a discretionary market-analysis toolkit.

It is most useful when the trader evaluates the relationship between:

market direction

confirmed structure

price imbalance

volume expansion

and Buy/Sell volume distribution

rather than interpreting any single visual element as an automatic trading signal.

Users are encouraged to test the indicator on historical and real-time data, understand each component independently, and build their own risk-management rules before using the information in live trading.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.