Inverted Fair Value Gap @Ivan
Forums › ProRealTime forum Français › Support ProBuilder › Inverted Fair Value Gap @Ivan
- This topic has 4 replies, 2 voices, and was last updated 3 weeks ago by
Alai-n.
-
-
05/16/2025 at 4:40 PM #247208
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?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125//-----------------------------------------------////PRC_Inverted FVG//version = 0//09.01.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-----------------------------------------------//// inputs//-----------------------------------------------//defparam drawonlastbaronly=truedispNum=7atrMult=0.25showbrokenFvg=0//-----------------------------------------------//// Atr calculation//-----------------------------------------------//if barindex<=200 and barindex>1 thenatr=averagetruerange[barindex](close)*atrMultelseatr=averagetruerange[200](close)*atrMultendif//-----------------------------------------------//// 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]=0n=n+1endifif 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]=0n=n+1endifif islastbarupdate thent1=0FOR i = n DOWNTO 0 DOt1=$fvgLeft[i]+1if t1<barindex thenfor j=barindex-t1 downto 0 doIF $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] = 1breakENDIFIF $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] = 1breakENDIFnextendifNEXTcount2=0t2=0for i=n downto 0 dot2=$invRight[i]+1if t2<barindex thenfor j=barindex-t2 downto 0 doif $fvgDir[i] = 1 and $State[i] = 1 and close[j] > $invTop[i] THENif count2<dispNum and showbrokenFvg thendrawrectangle($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)endifcount2=count2+1$State[i] = -1breakendifif $fvgDir[i] = -1 and $State[i] = 1 and close[j] < $invBot[i] THENif count2<dispNum and showbrokenFvg thendrawrectangle($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)endifcount2=count2+1$State[i] = -1breakendifnextendifnextcount=0for i=n downto 0 doif $State[i] = 1 and count < dispNum thencount=count+1if $fvgDir[i]=1 thendrawrectangle($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 thendrawrectangle($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)endifendifnextendif//-----------------------------------------------//returnMerci
05/19/2025 at 9:48 AM #24730205/20/2025 at 10:21 AM #247365Merci Iván
J’ai fait une tentative, mais j’ai cependant un message d’erreur, image jointe! Aurais-tu une idée ?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136//-----------------------------------------------//// PRC_Inverted FVG Modifié// Version = 1.0// Modifié selon les spécifications client//-----------------------------------------------//// Inputs//-----------------------------------------------//defparam drawonlastbaronly=truedispNum=7atrMult=0.25showbrokenFvg=0//-----------------------------------------------//// ATR Calculation//-----------------------------------------------//if barindex<=200 and barindex>1 thenatr=averagetruerange[barindex](close)*atrMultelseatr=averagetruerange[200](close)*atrMultendif//-----------------------------------------------//// FVG Detection (inchangé)//-----------------------------------------------//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]=0n=n+1endifif 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]=0n=n+1endif//-----------------------------------------------//// Nouvelle logique de validation IFVG//-----------------------------------------------//if islastbarupdate thent1=0FOR i = n DOWNTO 0 DOt1=$fvgLeft[i]+1if t1<barindex then// Calcul des extrêmes sur 3 bougiesif $fvgDir[i] = 1 then // FVG haussierhighestFVG = highest[3]($fvgTop[i])for j=barindex-t1 downto 0 doIF cbot[j] < $fvgBot[i] AND high[j] > highestFVG THEN$invLeft[i] = $fvgLeft[i]$invTop[i] = $fvgTop[i]$invRight[i] = barindex[j]$invBot[i] = $fvgBot[i]$State[i] = 1breakENDIFnextelsif $fvgDir[i] = -1 then // FVG baissierlowestFVG = lowest[3]($fvgBot[i])for j=barindex-t1 downto 0 doIF ctop[j] > $fvgTop[i] AND low[j] < lowestFVG THEN$invLeft[i] = $fvgLeft[i]$invTop[i] = $fvgTop[i]$invRight[i] = barindex[j]$invBot[i] = $fvgBot[i]$State[i] = 1breakENDIFnextendifendifNEXT// Gestion des FVG cassés (inchangé)count2=0t2=0for i=n downto 0 dot2=$invRight[i]+1if t2<barindex thenfor j=barindex-t2 downto 0 doif $fvgDir[i] = 1 and $State[i] = 1 and close[j] > $invTop[i] THENif count2<dispNum and showbrokenFvg thendrawrectangle($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)endifcount2=count2+1$State[i] = -1breakendifif $fvgDir[i] = -1 and $State[i] = 1 and close[j] < $invBot[i] THENif count2<dispNum and showbrokenFvg thendrawrectangle($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)endifcount2=count2+1$State[i] = -1breakendifnextendifnext// Affichage des IFVG valides (inchangé)count=0for i=n downto 0 doif $State[i] = 1 and count < dispNum thencount=count+1if $fvgDir[i]=1 thendrawrectangle($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 thendrawrectangle($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)endifendifnextendifreturn05/20/2025 at 12:27 PM #247370Oui, le problème vient de la façon dont tu calcules la valeur la plus haute/la plus basse des derniers FVG.
Si tu remplaces par ces lignes :
highestFVG = max($fvgTop[i], max($fvgTop[i-1], $fvgTop[i-2]))
lowestFVG = min($fvgBot[i], min($fvgBot[i-1], $fvgBot[i-2]))
De plus, la boucle devra aller de *n* à 2 pour éviter une erreur :
for i = n downto 2 do
05/23/2025 at 2:19 PM #247563Iván
Cela ne fonctionne pas comme je le souhaiterais, il y a quelque chose qui cloche! Je ne trouve pas quoi!
J’ai fait une demande au service programmation, je ne sais comment vous travaillez, qui fait et quoi et comment. Mais peut-être pourrais-tu y jeter un œil ?!Merci
-
AuthorPosts