Bonjour,
J’utilise un indicateur FVG trouvé sur le forum ProRealCode. Il fonctionne bien, mais sur les graphiques 5 et 15-30 minutes (avec 15 000 bougies), j’ai un problème d’affichage :
Les rectangles FVG non mitigés s’empilent à chaque bougie
Même avec une opacité faible (ex : 20), le fond devient très sombre
Si je mets une durée fixe (ex : 50, 300, 999999), les FVG disparaissent ou ne s’affichent plus
J’ai essayé plusieurs solutions avec l’IA mais sans succès.
Je souhaiterais garder la logique actuelle du code, mais pouvoir afficher les FVG non mitigés sans effet de sur-opacité ni disparition des anciennes FVG
Pourriez-vous m’aider à corriger ce point tout en gardant la structure du code ?
Merci d’avance,
//---------------------------------------------//
// PRC_Fair Value Gap modifié (visuel optimisé)
// Garde tous les FVG non mitigés visibles sans sur-opaquage
//---------------------------------------------//
thresholdPer = 0
auto = 0
dynamic = 0
mitigationsLevels = 1
//---------------------------------------------//
// Threshold
//---------------------------------------------//
if barindex > 0 and auto then
threshold = summation[barindex]((high - low) / low) / barindex
else
threshold = thresholdPer / 100
endif
//---------------------------------------------//
// FVG Detection
//---------------------------------------------//
bullFvg = low > high[2] and close[1] > high[2] and (low - high[2]) / high[2] > threshold
bearFvg = high < low[2] and close[1] < low[2] and (low[2] - high) / high > threshold
if bullFvg then
newFvgmax = low
newFvgmin = high[2]
newFvgisbull = 1
newFvgx = barindex
r = 8
g = 153
b = 129
a = 0
elsif bearFvg then
newFvgmax = low[2]
newFvgmin = high
newFvgisbull = 0
newFvgx = barindex
r = 244
g = 54
b = 69
a = 0
else
a = 100
endif
//---------------------------------------------//
// Anti-doublons
//---------------------------------------------//
alreadyExists = 0
for j = 0 to z do
if $newFvgx[j] = newFvgx then
alreadyExists = 1
break
endif
next
//---------------------------------------------//
// Bull FVG
//---------------------------------------------//
if bullFvg and alreadyExists = 0 then
if dynamic then
maxbullFvg = newFvgmax
minbullFvg = newFvgmin
endif
if dynamic = 0 then
$boxleft[z+1] = barindex[2]
$boxrigth[z+1] = barindex // extensible
$boxbot[z+1] = newFvgmin
$boxTop[z+1] = newFvgmax
endif
$newFvgmax[z+1] = newFvgmax
$newFvgmin[z+1] = newFvgmin
$newFvgisbull[z+1] = newFvgisbull
$newFvgx[z+1] = newFvgx
z = z + 1
bullcount = bullcount + 1
t = newFvgx
elsif dynamic then
maxBullFvg = max(min(close, maxBullFvg), minBullFvg)
endif
//---------------------------------------------//
// Bear FVG
//---------------------------------------------//
if bearFvg and alreadyExists = 0 then
if dynamic then
maxbearFvg = newFvgmax
minbearFvg = newFvgmin
endif
if dynamic = 0 then
$boxleft[z+1] = barindex[2]
$boxrigth[z+1] = barindex
$boxbot[z+1] = newFvgmin
$boxTop[z+1] = newFvgmax
endif
$newFvgmax[z+1] = newFvgmax
$newFvgmin[z+1] = newFvgmin
$newFvgisbull[z+1] = newFvgisbull
$newFvgx[z+1] = newFvgx
z = z + 1
bearcount = bearcount + 1
t = newFvgx
elsif dynamic then
minBearFvg = min(max(close, minBearFvg), maxBearFvg)
endif
//---------------------------------------------//
// Mitigated lines
//---------------------------------------------//
if z > 0 then
for i = z - 1 downto 0 do
if $newFvgisbull[i] = 1 and close < $newFvgmin[i] then
if dynamic = 0 then
$boxleft[i] = undefined
$boxrigth[i] = undefined
$boxbot[i] = undefined
$boxTop[i] = undefined
endif
$newFvgmax[i] = undefined
$newFvgmin[i] = undefined
$newFvgisbull[i] = undefined
$newFvgx[i] = undefined
bullMitigated = bullMitigated + 1
elsif $newFvgisbull[i] = 0 and close > $newFvgmax[i] then
if dynamic = 0 then
$boxleft[i] = undefined
$boxrigth[i] = undefined
$boxbot[i] = undefined
$boxTop[i] = undefined
endif
$newFvgmax[i] = undefined
$newFvgmin[i] = undefined
$newFvgisbull[i] = undefined
$newFvgx[i] = undefined
bearMitigated = bearMitigated + 1
endif
next
endif
//---------------------------------------------//
// Unmitigated lines (visuel)
//---------------------------------------------//
if islastbarupdate and z > 0 and dynamic = 0 then
for i = z downto 0 do
if $boxleft[i] <> undefined then
if $boxrigth[i] < barindex then
$boxrigth[i] = barindex
endif
if $newFvgisbull[i] = 1 then
drawrectangle($boxleft[i], $boxbot[i], $boxrigth[i], $boxTop[i]) fillcolor(128, 0, 0, 10) coloured(128, 0, 0, 10)
else
drawrectangle($boxleft[i], $boxbot[i], $boxrigth[i], $boxTop[i]) fillcolor(47, 79, 79, 10) coloured(47, 79, 79, 10)
endif
hauteur = $boxTop[i] - $boxbot[i]
niv25 = $boxbot[i] + hauteur * 0.25
niv50 = $boxbot[i] + hauteur * 0.5
niv75 = $boxbot[i] + hauteur * 0.75
drawsegment($boxleft[i], niv25, $boxrigth[i], niv25) coloured(0, 0, 0, 64)
drawsegment($boxleft[i], niv50, $boxrigth[i], niv50) coloured(0, 0, 0, 64)
drawsegment($boxleft[i], niv75, $boxrigth[i], niv75) coloured(0, 0, 0, 64)
endif
next
endif
//---------------------------------------------//
// Dynamic view (si activé)
if dynamic then
if newFvgisbull then
colorbetween($newFvgmax[z], $newFvgmin[z], r, g, b, a)
else
colorbetween($newFvgmax[z], $newFvgmin[z], r, g, b, a)
endif
endif
//---------------------------------------------//
return