Inverted Fair Value Gap @Ivan

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #247208 quote
    Alai-n
    Participant
    Veteran

    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

    #247302 quote
    Iván González
    Moderator
    Master

    Holà. Vous êtes sur ces lignes :

    IF $fvgDir[i] = 1 AND cbot[j] < $fvgBot[i] THEN
    ...
    IF $fvgDir[i] = -1 AND ctop[j] > $fvgTop[i] THEN
    
    Alai-n thanked this post
    #247365 quote
    Alai-n
    Participant
    Veteran

    Merci Iván

    J’ai fait une tentative, mais j’ai cependant un message d’erreur, image jointe! Aurais-tu une idée ?

    //-----------------------------------------------//
    // PRC_Inverted FVG Modifié
    // Version = 1.0
    // Modifié selon les spécifications client
    //-----------------------------------------------//
    // 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 (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]=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
    
    //-----------------------------------------------//
    // Nouvelle logique de validation IFVG
    //-----------------------------------------------//
    if islastbarupdate then
    t1=0
    FOR i = n DOWNTO 0 DO
    t1=$fvgLeft[i]+1
    if t1<barindex then
    // Calcul des extrêmes sur 3 bougies
    if $fvgDir[i] = 1 then // FVG haussier
    highestFVG = highest[3]($fvgTop[i])
    for j=barindex-t1 downto 0 do
    IF 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] = 1
    break
    ENDIF
    next
    elsif $fvgDir[i] = -1 then // FVG baissier
    lowestFVG = lowest[3]($fvgBot[i])
    for j=barindex-t1 downto 0 do
    IF 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] = 1
    break
    ENDIF
    next
    endif
    endif
    NEXT
    
    // Gestion des FVG cassés (inchangé)
    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
    
    // Affichage des IFVG valides (inchangé)
    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
    
    #247370 quote
    Iván González
    Moderator
    Master

    Oui, 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

    #247563 quote
    Alai-n
    Participant
    Veteran

    Ivá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

    #249142 quote
    slimanb
    Participant
    New

    Bonjour Ivan

    je te remercie pour cet indicateur tres important en ICT.

    quand je veux mettre un signal d’alerte pour detecter un pullback sur le IFVG ( ligne mediane ou borne ) j’ai un signal  d’alerte:”impossible de placer une alerte sur l’indicateur car il n’a actuellement pas de valeur. Si l’indicateur utilise un décalage dans le passé ,supprimez ce décalage dans les réglages de l’indicateur avant de creer l’alerte”. pourras tu m’expliquer ce que je dois faire  et est il possible de choisir une des options sur le parametre  soit la borne soit la ligne 50%de l’IFVG.Merci

    #249161 quote
    Alai-n
    Participant
    Veteran
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Inverted Fair Value Gap @Ivan


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Alai-n @alai-n Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by Alai-n
6 months, 1 week ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 05/16/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...