Fair Gap Value

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #249717 quote
    PhilippePhilippe
    Participant
    Junior

    Bonjour à tous,

    J’essaie en vain de coder un FGV sur 3 bougies et de me les afficher tous tant qu’ils ne sont pas comblés.

    J’ai de code qui ne m’affiche rien du tout :

    // ———- Paramètres ———-
    MinGapPts = 1
    ExtendBars = 30 // si ExtendUntilFill = 0
    ExtendUntilFill = 1 // 1 = rectangle disparaît quand comblé

    minGap = MinGapPts * pointsize

    // ———- Etats persistants ———-
    ONCE bullActive = 0
    ONCE bearActive = 0

    ONCE bullTop = 0.0
    ONCE bullBot = 0.0
    ONCE bearTop = 0.0
    ONCE bearBot = 0.0

    ONCE bullStart = 0
    ONCE bearStart = 0

    // ———- Détection ———-
    bullCond = (low > high[2]) AND (low – high[2] >= minGap)
    bearCond = (high < low[2]) AND (low[2] – high >= minGap)

    IF bullCond THEN
    bullTop = high[2] // haut du rectangle = high de la 1ère bougie
    bullBot = low[0] // bas du rectangle = low de la 3ème bougie
    bullStart = barindex
    bullActive = 1
    ENDIF

    IF bearCond THEN
    bearTop = high[0] // haut du rectangle = high de la 3ème bougie
    bearBot = low[2] // bas du rectangle = low de la 1ère bougie
    bearStart = barindex
    bearActive = 1
    ENDIF

    // ———- Gestion persistance ———-
    IF ExtendUntilFill = 1 THEN
    IF bullActive = 1 AND low <= bullBot THEN
    bullActive = 0
    ENDIF
    IF bearActive = 1 AND high >= bearTop THEN
    bearActive = 0
    ENDIF
    ENDIF

    // ———- Dessin ———-
    IF bullActive = 1 THEN
    bullEnd = barindex
    IF ExtendUntilFill = 0 THEN
    bullEnd = bullStart + ExtendBars
    IF barindex > bullEnd THEN
    bullActive = 0
    ENDIF
    ENDIF
    IF bullEnd <= bullStart THEN
    bullEnd = bullStart + 1
    ENDIF
    DRAWRECTANGLE(bullStart, bullTop, bullEnd, bullBot) COLOURED(0,180,0,60)
    ENDIF

    IF bearActive = 1 THEN
    bearEnd = barindex
    IF ExtendUntilFill = 0 THEN
    bearEnd = bearStart + ExtendBars
    IF barindex > bearEnd THEN
    bearActive = 0
    ENDIF
    ENDIF
    IF bearEnd <= bearStart THEN
    bearEnd = bearStart + 1
    ENDIF
    DRAWRECTANGLE(bearStart, bearTop, bearEnd, bearBot) COLOURED(220,0,0,60)
    ENDIF

    // ———- Séries pour RETURN ———-
    bullTopPlot = undefined
    bullBotPlot = undefined
    bearTopPlot = undefined
    bearBotPlot = undefined

    IF bullActive = 1 THEN
    bullTopPlot = bullTop
    bullBotPlot = bullBot
    ENDIF
    IF bearActive = 1 THEN
    bearTopPlot = bearTop
    bearBotPlot = bearBot
    ENDIF

    RETURN bullTopPlot AS “FVG+ Haut”, bullBotPlot AS “FVG+ Bas”, bearTopPlot AS “FVG- Haut”, bearBotPlot AS “FVG- Bas”

     

    Avez-vous une idée ?

     

    Merci par avance,

     

    Bien Cordialement,

    #249827 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Votre code:

    // ———- Gestion persistance ———-
    IF ExtendUntilFill = 1 THEN
       IF bullActive = 1 AND low <= bullBot THEN
          bullActive = 0
       ENDIF
       IF bearActive = 1 AND high >= bearTop THEN
          bearActive = 0
       ENDIF
    ENDIF

    Il faut le changer comme ceci, sans le symbole “=” :

    // ———- Gestion persistance ———-
    IF ExtendUntilFill = 1 THEN
       IF bullActive = 1 AND low < bullBot THEN
          bullActive = 0
       ENDIF
       IF bearActive = 1 AND high > bearTop THEN
          bearActive = 0
       ENDIF
    ENDIF

    ou changez-le comme ceci, si vous préférez utiliser “=”, indiquez simplement que la vérification doit être effectuée dans la barre suivante :

    // ———- Gestion persistance ———-
    IF ExtendUntilFill = 1 THEN
       IF bullActive = 1 AND low <= bullBot AND BarIndex > bullStart THEN
          bullActive = 0
       ENDIF
       IF bearActive = 1 AND high >= bearTop AND BarIndex > bearStart THEN
          bearActive = 0
       ENDIF
    ENDIF

    parce que LOW ou HIGH sont immédiatement égaux  à leurs-même.

    #249828 quote
    PhilippePhilippe
    Participant
    Junior

    Merci

    robertogozzi thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Fair Gap Value


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Philippe @philippe-c Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by PhilippePhilippe
1 year, 1 month ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 08/14/2025
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...