Bonjour Iván
Je souhaiterai apporter une modification dans le protocole de validation des IFVG dans ce code. C’est à dire que je souhaiterai valider un nouvel IFVG haussier seulement lorsque high actuel a dépassé le highest[3] de l’IFVG. Puis valider un IFVG baissier seulement lorsque le low actuel a dépassé le lowest[3] de l’IFVG.
Dans ce code, si je comprends bien la validation se fait lorsque le Gap est comblé entre low[1] et high[3], mais je ne trouve pas ça complet!
Pourrais-tu m’indiquer les lignes qui gèrent cela?
//-----------------------------------------------//
//PRC_Inverted FVG
//version = 0
//09.01.2025
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-----------------------------------------------//
// inputs
//-----------------------------------------------//
defparam drawonlastbaronly=true
dispNum=7
atrMult=0.25
showbrokenFvg=0
//-----------------------------------------------//
// Atr calculation
//-----------------------------------------------//
if barindex<=200 and barindex>1 then
atr=averagetruerange[barindex](close)*atrMult
else
atr=averagetruerange[200](close)*atrMult
endif
//-----------------------------------------------//
// FVG Detection
//-----------------------------------------------//
fvgUp=low>high[2] and close[1]>high[2]
fvgDown=high<low[2] and close[1]<low[2]
ctop=max(close,open)
cbot=min(close,open)
if fvgUp and abs(low-high[2])>atr then
$fvgLeft[n+1]=barindex[1]
$fvgTop[n+1]=low
$fvgRight[n+1]=barindex
$fvgBot[n+1]=high[2]
$fvgMid[n+1]=(low+high[2])/2
$fvgDir[n+1]=1
$State[n+1]=0
n=n+1
endif
if fvgDown and abs(low[2]-high)>atr then
$fvgLeft[n+1]=barindex[1]
$fvgTop[n+1]=low[2]
$fvgRight[n+1]=barindex
$fvgBot[n+1]=high
$fvgMid[n+1]=(low[2]+high)/2
$fvgDir[n+1]=-1
$State[n+1]=0
n=n+1
endif
if islastbarupdate then
t1=0
FOR i = n DOWNTO 0 DO
t1=$fvgLeft[i]+1
if t1<barindex then
for j=barindex-t1 downto 0 do
IF $fvgDir[i] = 1 AND cbot[j] < $fvgBot[i] THEN
$invLeft[i] = $fvgLeft[i]
$invTop[i] = $fvgTop[i]
$invRight[i] = barindex[j]
$invBot[i] = $fvgBot[i]
$State[i] = 1
break
ENDIF
IF $fvgDir[i] = -1 AND ctop[j] > $fvgTop[i] THEN
$invLeft[i] = $fvgLeft[i]
$invTop[i] = $fvgTop[i]
$invRight[i] = barindex[j]
$invBot[i] = $fvgBot[i]
$State[i] = 1
break
ENDIF
next
endif
NEXT
count2=0
t2=0
for i=n downto 0 do
t2=$invRight[i]+1
if t2<barindex then
for j=barindex-t2 downto 0 do
if $fvgDir[i] = 1 and $State[i] = 1 and close[j] > $invTop[i] THEN
if count2<dispNum and showbrokenFvg then
drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("green",0)fillcolor("green",10)
drawsegment($invRight[i],$invTop[i],barindex[j],$invTop[i])coloured("blue",100)style(dottedline)
endif
count2=count2+1
$State[i] = -1
break
endif
if $fvgDir[i] = -1 and $State[i] = 1 and close[j] < $invBot[i] THEN
if count2<dispNum and showbrokenFvg then
drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("red",0)fillcolor("red",10)
drawsegment($invRight[i],$invTop[i],barindex[j],$invTop[i])coloured("blue",100)style(dottedline)
endif
count2=count2+1
$State[i] = -1
break
endif
next
endif
next
count=0
for i=n downto 0 do
if $State[i] = 1 and count < dispNum then
count=count+1
if $fvgDir[i]=1 then
drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("green",0)fillcolor("green",50)
drawrectangle($invRight[i],$invTop[i],barindex+10,$invBot[i])coloured("red",0)fillcolor("red",50)
drawsegment($invLeft[i],($invBot[i]+$invTop[i])/2,barindex+10,($invBot[i]+$invTop[i])/2)coloured("grey",75)style(dottedline3)
elsif $fvgDir[i]=-1 then
drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("red",0)fillcolor("red",50)
drawrectangle($invRight[i],$invTop[i],barindex+10,$invBot[i])coloured("green",0)fillcolor("green",50)
drawsegment($invLeft[i],($invBot[i]+$invTop[i])/2,barindex+10,($invBot[i]+$invTop[i])/2)coloured("grey",75)style(dottedline3)
endif
endif
next
endif
//-----------------------------------------------//
return
Merci