Fair Value Gap (FVG) Algorithm: Automated Detection in Pine Script v6
Order Flow & Imbalance

Fair Value Gap (FVG) Algorithm: Automated Detection in Pine Script v6

Fair Value Gap FVG algorithm on TradingView

A Fair Value Gap (FVG) occurs during aggressive single-sided price displacement where aggressive market orders consume liquidity without reciprocal two-way auction matching. On a 3-candle sequence, an imbalance forms between Candle 1's wick and Candle 3's wick.

Mathematical 3-Bar Imbalance Formula

Pine Script v6 Real-Time FVG Tracker with Mitigation

//@version=6 indicator("Dynamic FVG Mitigation Tracker", overlay=true) bullishFVG = low > high[2] bearishFVG = high < low[2] if bullishFVG box.new(left=bar_index-2, top=low, right=bar_index+5, bottom=high[2], bgcolor=color.new(color.green, 80), border_color=color.green) if bearishFVG box.new(left=bar_index-2, top=low[2], right=bar_index+5, bottom=high, bgcolor=color.new(color.red, 80), border_color=color.red)
SmartCat Algo FVG and Liquidity Mitigation
Figure 1: Institutional FVG retests acting as high-probability entry magnets.

Full Institutional SMC Codebase

SmartCat Algo automates FVGs, Order Blocks, and multi-stage risk management without subscription locks. Download the Pine Script v6 source today.

Get SmartCat Algo (8 One-Time)