voila ça donne ça.
//@version=5
//indicator(“Fair Value Gap (FVG)”, overlay=true)
// Parameters
fvgLookback = 2//input.int(1, title=”Lookback (candle before and after)”, minval=1)
// Données des bougies
prevHigh = high[fvgLookback]
prevLow = low[fvgLookback]
nextHigh = high[0]
nextLow = low[0]
// Calcul du FVG
bullishFVG = low > prevHigh
bearishFVG = high < prevLow
// Affichage des FVGs
If bullishFVG then
DrawRectangle((BarIndex-fvgLookback),prevHigh,BarIndex,low)Coloured(“YELLOW”,255)FillColor(0,0,250)
Median=prevHigh+(Low-prevHigh)/2
DrawSegment(BarIndex-fvgLookback,Median,BarIndex,Median)Coloured(“BLACK”)
DrawText(“#Median#”,BarIndex-1,Median,dialog,bold,15)
EndIf
If bearishFVG then
DrawRectangle(BarIndex,High,(BarIndex-fvgLookback),prevLow)Coloured(“YELLOW”,255)FillColor(0,0,250)
Median=High+(prevLow-High)/2
DrawSegment(BarIndex-fvgLookback,Median,BarIndex,Median)Coloured(“BLACK”)
DrawText(“#Median#”,BarIndex-1,Median,dialog,bold,15)
EndIf
Return