Corriger un code ProBuilder

Forums ProRealTime forum Français Support ProBuilder Corriger un code ProBuilder

Viewing 2 posts - 1 through 2 (of 2 total)
  • #238550

    Bonjour à tous,

    Mon code ProBuilder ne fonctionne pas. Je ne trouve pas les erreurs.

    Je vous serais reconnaissant de bien vouloir corriger les fautes ou de m’indiquer comment le faire fonctionner.

    Merci par avance,

    Majez

    Voici le code :

    // Initialisation des variables
    DEFPARAM CalculateOnLastBarOnly = False

    //—————————————————————————–
    // Paramètres
    //—————————————————————————–
    options = “Options”
    sp1 = ” ”
    sp2 = ” ”
    hl = “High / Low” + sp1
    ny_ = “New York” + sp1
    lo_ = “London Open”
    lc_ = “London Close”
    as_ = “Asian”

    //—————————————————————————–
    // Réglages utilisateur
    //—————————————————————————–
    i_mode = ParamStr(“Mode”, “Present”, “Present|Historical”)

    // Structure de marché : Détection du Market Structure Shift
    showMS = Param(“Afficher Market Structure”, 1) // booléen
    len = Param(“Longueur”, 5, 3, 10) // longueur entre 3 et 10

    iMSS = Param(“Afficher MSS”, 1) // booléen
    cMSSbl = RGB(0, 230, 161) // Couleur MSS haussier (bullish)
    cMSSbr = RGB(230, 4, 0) // Couleur MSS baissier (bearish)

    iBOS = Param(“Afficher BOS”, 1) // booléen
    cBOSbl = RGB(0, 230, 161) // Couleur BOS haussier (bullish)
    cBOSbr = RGB(230, 4, 0) // Couleur BOS baissier (bearish)

    //—————————————————————————–
    // Code pour détecter la structure du marché
    //—————————————————————————–

    // Exemple simple pour les Market Structure Shift (MSS) ou Break of Structure (BOS)
    if showMS then
    // Détection du MSS ou BOS en fonction des conditions
    if (ConditionPourMSS()) then
    // Affichage du MSS haussier ou baissier selon la logique
    IF iMSS THEN
    IF ConditionHaussiere THEN
    DRAWTEXT(“MSS Bullish”, BarIndex, High, cMSSbl)
    ELSE
    DRAWTEXT(“MSS Bearish”, BarIndex, Low, cMSSbr)
    ENDIF
    ENDIF

    // Affichage du BOS si activé
    IF iBOS THEN
    IF ConditionHaussiere THEN
    DRAWTEXT(“BOS Bullish”, BarIndex, High, cBOSbl)
    ELSE
    DRAWTEXT(“BOS Bearish”, BarIndex, Low, cBOSbr)
    ENDIF
    ENDIF
    ENDIF
    ENDIF

    // Paramètres utilisateur
    sDispl = Param(“Afficher Displacement”, False) // booléen pour l’affichage du Displacement
    perc_Body = 0.36 // Pourcentage du corps de la bougie
    bxBack = 10 // Paramètre pour le Lookback de l’OB

    // Volume Imbalance (VI)
    sVimbl = Param(“Afficher Volume Imbalance”, True) // Affichage de l’Imbalance
    visVim = Param(“Nombre Visible VI”, 2, 2, 100) // Nombre de Volume Imbalance visibles
    cVimbl = RGB(6, 178, 208) // Couleur pour Volume Imbalance

    // Order Blocks (OB)
    showOB = Param(“Afficher Order Blocks”, True) // Affichage des Order Blocks
    length = Param(“Swing Lookback”, 10, 3, 100) // Période de lookback pour les Swing High/Low
    showBull = Param(“Afficher dernier Bullish OB”, 1, 0, 1) // Afficher le dernier OB haussier
    showBear = Param(“Afficher dernier Bearish OB”, 1, 0, 1) // Afficher le dernier OB baissier
    useBody = Param(“Utiliser le corps des bougies”, True) // Utilisation du corps de la bougie

    // Style des Order Blocks
    bullCss = RGB(62, 137, 250) // Couleur pour Bullish OB
    bullBrkCss = RGB(71, 133, 249) // Couleur pour Bullish Break

    bearCss = RGB(255, 49, 49) // Couleur pour Bearish OB
    bearBrkCss = RGB(249, 255, 87) // Couleur pour Bearish Break

    // Historique des changements de polarité
    showLabels = Param(“Afficher changements de polarité historiques”, False) // booléen pour l’affichage des changements historiques

    //—————————————————————————–
    // Logique pour l’affichage des Order Blocks, Displacement et Volume Imbalance
    //—————————————————————————–

    IF sDispl THEN
    // Logique pour gérer le Displacement
    // Implémenter la logique du displacement ici
    ENDIF

    IF sVimbl THEN
    // Logique pour afficher le Volume Imbalance
    FOR i = 0 TO visVim DO
    // Calcul et affichage des Imbalances selon la logique définie
    // Exemple : DRAWTEXT(“Volume Imbalance”, BarIndex-i, High-i, cVimbl)
    NEXT
    ENDIF

    IF showOB THEN
    // Logique pour les Order Blocks (OB)
    IF showBull THEN
    // Détection et affichage du dernier Bullish OB
    // Exemple : DRAWTEXT(“Bullish OB”, BarIndex, High, bullCss)
    ENDIF

    IF showBear THEN
    // Détection et affichage du dernier Bearish OB
    // Exemple : DRAWTEXT(“Bearish OB”, BarIndex, Low, bearCss)
    ENDIF

    IF showLabels THEN
    // Affichage des changements historiques de polarité
    // Exemple : DRAWTEXT(“Polarity Change”, BarIndex, High, RGB(255,255,255))
    ENDIF
    ENDIF

    // Paramètres utilisateur pour la Liquidité
    showLq = Param(“Afficher Liquidité”, True) // Afficher la liquidité
    a = 10 / ParamFloat(“Marge”, 4, 2, 7, 0.1) // Paramètre pour la marge
    visLiq = Param(“Nombre de boîtes de Liquidité visibles”, 2, 1, 50) // Nombre de boîtes de liquidité visibles
    cLIQ_B = RGB(250, 69, 28) // Couleur pour la Buy-side Liquidity
    cLIQ_S = RGB(28, 228, 250) // Couleur pour la Sell-side Liquidity

    // Paramètres utilisateur pour les Fair Value Gaps (FVG)
    shwFVG = Param(“Afficher FVG”, True) // Affichage des FVG
    i_BPR = Param(“Afficher Balance Price Range”, False) // Affichage du Balance Price Range (BPR)
    i_FVG = ParamStr(“FVG Type”, “FVG”, “FVG|IFVG”) // Choix entre FVG et IFVG
    visBxs = Param(“Nombre de FVG visibles”, 2, 1, 20) // Nombre de FVG visibles

    // Styles pour les FVG
    cFVGbl = RGB(0, 230, 118) // Couleur pour Bullish FVG
    cFVGblBR = RGB(128, 128, 0) // Couleur pour Bullish Break
    cFVGbr = RGB(255, 82, 82) // Couleur pour Bearish FVG
    cFVGbrBR = RGB(255, 0, 0) // Couleur pour Bearish Break

    // Paramètres utilisateur pour NWOG/NDOG
    iNWOG = Param(“Afficher NWOG”, True) // Affichage des NWOG
    cNWOG1 = RGB(255, 82, 82) // Couleur principale pour NWOG
    cNWOG2 = RGB(178, 181, 190) // Couleur secondaire pour NWOG
    maxNWOG = Param(“Nombre max de NWOG affichés”, 3, 0, 50) // Nombre maximal de NWOG visibles

    iNDOG = Param(“Afficher NDOG”, False) // Affichage des NDOG
    cNDOG1 = RGB(255, 152, 0) // Couleur principale pour NDOG
    cNDOG2 = RGB(77, 208, 225) // Couleur secondaire pour NDOG
    maxNDOG = Param(“Nombre max de NDOG affichés”, 1, 0, 50) // Nombre maximal de NDOG visibles

    //—————————————————————————–
    // Logique d’affichage de la Liquidité, FVG, NWOG/NDOG
    //—————————————————————————–

    // Liquidité
    IF showLq THEN
    // Logique pour afficher les boîtes de liquidité (buy-side et sell-side)
    FOR i = 0 TO visLiq DO
    // Calcul et affichage des boîtes de liquidité
    // Exemple : DRAWTEXT(“Buy-side Liquidity”, BarIndex-i, High-i, cLIQ_B)
    // Exemple : DRAWTEXT(“Sell-side Liquidity”, BarIndex-i, Low-i, cLIQ_S)
    NEXT
    ENDIF

    // FVG
    IF shwFVG THEN
    FOR i = 0 TO visBxs DO
    // Logique pour afficher les Fair Value Gaps (FVG)
    IF i_FVG == “FVG” THEN
    // Affichage des Bullish et Bearish FVG
    IF ConditionBullishFVG THEN
    DRAWTEXT(“Bullish FVG”, BarIndex-i, High-i, cFVGbl)
    ELSEIF ConditionBearishFVG THEN
    DRAWTEXT(“Bearish FVG”, BarIndex-i, Low-i, cFVGbr)
    ENDIF
    ELSE
    // Logique pour les IFVG (Implied Fair Value Gaps)
    ENDIF
    NEXT
    ENDIF

    // NWOG/NDOG
    IF iNWOG THEN
    FOR i = 0 TO maxNWOG DO
    // Affichage des NWOG
    DRAWTEXT(“NWOG”, BarIndex-i, High-i, cNWOG1)
    NEXT
    ENDIF

    IF iNDOG THEN
    FOR i = 0 TO maxNDOG DO
    // Affichage des NDOG
    DRAWTEXT(“NDOG”, BarIndex-i, Low-i, cNDOG1)
    NEXT
    ENDIF

    // Paramètres pour Fibonacci
    iFib = ParamStr(“Fibonacci entre les derniers :”, “NONE”, “FVG|BPR|OB|Liq|VI|NWOG|NONE”) // Type de Fibonacci
    iExt = Param(“Étendre les lignes”, False) // Étendre les lignes de Fibonacci

    // Paramètres pour les Killzones
    showKZ = Param(“Afficher Killzones”, False) // Afficher les Killzones

    // Paramètres pour New York
    showNy = Param(“Afficher New York”, True) AND showKZ // Afficher New York si les Killzones sont activées
    nyCss = RGB(255, 93, 0, 93) // Couleur pour la Killzone New York

    // Paramètres pour London Open
    showLdno = Param(“Afficher London Open”, True) AND showKZ // Afficher London Open si les Killzones sont activées
    ldnoCss = RGB(0, 188, 212, 93) // Couleur pour la Killzone London Open

    // Paramètres pour London Close
    showLdnc = Param(“Afficher London Close”, True) AND showKZ // Afficher London Close si les Killzones sont activées
    ldncCss = RGB(33, 87, 243, 93) // Couleur pour la Killzone London Close

    // Paramètres pour l’Asie
    showAsia = Param(“Afficher Asian Session”, True) AND showKZ // Afficher Asian Session si les Killzones sont activées
    asiaCss = RGB(233, 30, 99, 93) // Couleur pour la Killzone Asie

    //—————————————————————————–
    // Calculs Généraux
    //—————————————————————————–
    n = BarIndex
    hi = High
    lo = Low
    tf_msec = TimeFrame * 1000
    maxSize = 50
    atr = AverageTrueRange[10]
    per = (i_mode == “Present”) ? (LastBarIndex – BarIndex <= 500) : True
    perB = (LastBarIndex – BarIndex <= 1000)
    xloc = (iFib == “OB”) ? BarIndex : BarIndex
    ext = (iExt) ? ExtendRight : ExtendNone
    plus = (iFib == “OB”) ? tf_msec * 50 : 50
    mx = Max(Close, Open)
    mn = Min(Close, Open)
    body = Abs(Close – Open)
    meanBody = Average[Len](body)
    max = (useBody) ? mx : High
    min = (useBody) ? mn : Low
    blBrkConf = 0
    brBrkConf = 0
    isDark = (GetRed(BackgroundColor) < 80 AND GetGreen(BackgroundColor) < 80 AND GetBlue(BackgroundColor) < 80)

    //—————————————————————————–
    // Types Définis par l’Utilisateur
    //—————————————————————————–
    TYPE ZZ
    IntArray d
    IntArray x
    FloatArray y
    BoolArray b

    TYPE ln_d
    Line l
    Int d

    TYPE _2ln_lb
    Line l1
    Line l2
    Label lb

    TYPE bx_ln
    Box b
    Line l

    TYPE bx_ln_lb
    Box bx
    Line ln
    Label lb

    TYPE mss
    Int dir
    LineArray l_mssBl
    LineArray l_mssBr
    LineArray l_bosBl
    LineArray l_bosBr
    LabelArray lbMssBl
    LabelArray lbMssBr
    LabelArray lbBosBl
    LabelArray lbBosBr

    TYPE liq
    Box bx
    Bool broken
    Bool brokenTop
    Bool brokenBtm
    Line ln

    TYPE ob
    Float top = NA
    Float btm = NA
    Int loc = BarIndex
    Bool breaker = False
    Int break_loc = NA

    TYPE swing
    Float y = NA
    Int x = NA
    Bool crossed = False

    TYPE FVG
    Box box
    Bool active
    Int pos

    // Création d’une instance de mss
    VAR mss MSS = mss.new(
    0,
    Array.NewLineArray(),
    Array.NewLineArray(),
    Array.NewLineArray(),
    Array.NewLineArray(),
    Array.NewLabelArray(),
    Array.NewLabelArray(),
    Array.NewLabelArray(),
    Array.NewLabelArray()
    )

    //—————————————————————————–
    // Variables
    //—————————————————————————–
    DEFparam “MaxBarsBack” = 1000

    // Variables pour les jours
    once friClosePrice = Undefined
    once friCloseIndex = Undefined
    once monOpenPrice = Undefined
    once monOpenIndex = Undefined

    // Variables pour les jours précédents et actuels
    once prevDayClosePrice = Undefined
    once prevDayCloseIndex = Undefined
    once currDayOpenPrice = Undefined
    once currDayOpenIndex = Undefined

    // Autres initialisations de variables
    vimbalArray = []
    liqBullArray = []
    liqBearArray = []
    bullishOBArray = []
    bearishOBArray = []

    fvgUpArray = []
    fvgDnArray = []
    bprUpArray = []
    bprDnArray = []

    ZZArray = []

    //—————————————————————————–
    // Fonctions
    //—————————————————————————–
    Function inOutZZ(int d, int x1, float y1, int x2, float y2, int color, bool condition)
    Begin
    // Ajouter la logique pour le calcul des zigzags
    End

    Function timeInRange(res, sess)
    Begin
    // Vérifier si le temps est dans la plage spécifiée
    Return (Not IsNullValue(Timeframe));
    End

    Function setLine(lineId, x1, y1, x2, y2)
    Begin
    DrawLine(x1, y1, x2, y2, lineId);
    End

    Function clearLines(lineArray)
    Begin
    For Each line In lineArray
    DeleteLine(line);
    Next
    End

    Function notransp(color)
    Begin
    Return RGB(ColorRed(color), ColorGreen(color), ColorBlue(color));
    End

    //—————————————————————————–
    // Swing Calculations
    //—————————————————————————–
    Function calculateSwing(len)
    Begin
    topSwing = Highest[len](High)
    bottomSwing = Lowest[len](Low)

    If (High[len] > topSwing) Then
    topSwingDetected = True;
    Else If (Low[len] < bottomSwing) Then
    bottomSwingDetected = True;
    EndIf
    End

    //—————————————————————————–
    // Dessin des OB et zones de liquidité
    //—————————————————————————–
    Function drawLiquidity(left, color)
    Begin
    maxBarsBack(1000)
    x2 = BarIndex – 1
    pivotHigh = Highest[Left](High)
    pivotLow = Lowest[Left](Low)

    // Logique pour dessiner les boîtes de liquidité acheteuse/vendeuse
    If (ShowLiquidity And pivotHigh) Then
    // Calcul et dessin des liquidités
    EndIf

    If (pivotLow) Then
    // Calcul et dessin des liquidités
    EndIf
    End

    // Déclaration des variables
    def i_mode = “Present”;
    def showMS = 1; // Affichage du Market Structure Shift
    def iBOS = 1; // Déclaration de la Break Of Structure (BOS)
    def n = barindex; // Utilisation de l’index des barres pour identifier les niveaux

    // Market Structure Shift (MSS)
    if (showMS) then
    iH = iff(aZZ[2] == 1, 2, 1);
    iL = iff(aZZ[2] == -1, 2, 1);

    // MSS haussier
    if (close > aZZ[iH] and aZZ[iH] == 1 and MSSdir < 1) then
    MSSdir = 1;
    if (i_mode == “Present”) then
    MSSL_mssBl = 0;
    MSSL_mssBr = 0;
    // Ajout des lignes pour MSS haussier
    drawline(n, aZZ[iH], n + 10, aZZ[iH], color = color.blue);
    drawtext(“MSS”, n, aZZ[iH], color = color.blue);
    endif;
    endif;

    // MSS baissier
    if (close < aZZ[iL] and aZZ[iL] == -1 and MSSdir > -1) then
    MSSdir = -1;
    if (i_mode == “Present”) then
    MSSL_mssBl = 0;
    MSSL_mssBr = 0;
    // Ajout des lignes pour MSS baissier
    drawline(n, aZZ[iL], n + 10, aZZ[iL], color = color.red);
    drawtext(“MSS”, n, aZZ[iL], color = color.red);
    endif;
    endif;

    // BOS haussier
    if (MSSdir == 1 and close > aZZ[iH] and iBOS) then
    drawline(n, aZZ[iH], n + 10, aZZ[iH], color = color.green);
    endif;

    // BOS baissier
    if (MSSdir == -1 and close < aZZ[iL] and iBOS) then
    drawline(n, aZZ[iL], n + 10, aZZ[iL], color = color.red);
    endif;
    endif;

    // Gestion des Killzones
    def ny = time(“0700”, “0900”) and showNy;
    def ldn_open = time(“0700”, “1000”) and showLdnOpen;
    def ldn_close = time(“1500”, “1700”) and showLdnClose;
    def asian = time(“1000”, “1400”) and showAsian;

    // Pivots
    def ph = highest(3, 1);
    def pl = lowest(3, 1);

    // Bougies
    def L_body = high – max < body * perc_Body and min – low < body * perc_Body;
    def L_bodyUP = body > meanBody and L_body and close > open;
    def L_bodyDN = body > meanBody and L_body and close < open;

    // Détection d’un déséquilibre
    def imbalanceUP = L_bodyUP[1] and (i_FVG == “FVG” ? low > high[2] : low < high[2]);
    def imbalanceDN = L_bodyDN[1] and (i_FVG == “FVG” ? high < low[2] : high > low[2]);

    // Détection du déséquilibre de volume
    def vImb_Bl = open > close[1] and high[1] > low and close > close[1] and open > open[1] and high[1] < min;
    def vImb_Br = open < close[1] and low[1] < high and close < close[1] and open < open[1] and low[1] > max;

    if (vImb_Bl) then
    drawline(n – 1, max[1], n + 3, max[1], color = color.blue);
    drawtext(“VI”, n + 3, avg(max[1], min), color = color.blue);
    endif;

    if (vImb_Br) then
    drawline(n – 1, min[1], n + 3, min[1], color = color.red);
    drawtext(“VI”, n + 3, avg(min[1], max), color = color.red);
    endif;

    // Balance Price Range (overlap of 2 latest FVG bull/bear)
    if i_BPR and bFVG_UP.size() > 0 and bFVG_DN.size() > 0 then
    bxUP = bFVG_UP.get(0)
    bxDN = bFVG_DN.get(0)

    bxUPbtm = bxUP.box.get_bottom()
    bxDNbtm = bxDN.box.get_bottom()
    bxUPtop = bxUP.box.get_top()
    bxDNtop = bxDN.box.get_top()

    left = min(bxUP.box.get_left(), bxDN.box.get_left())
    right = max(bxUP.box.get_right(), bxDN.box.get_right())

    // Check if boxes overlap
    if bxUPbtm < bxDNtop and bxDNbtm < bxUPbtm then
    if left == bBPR_UP.get(0).box.get_left() then
    if bBPR_UP.get(0).active then
    bBPR_UP.get(0).box.set_right(right)
    else
    bBPR_UP.unshift(FVG.new(
    box.new(left, bxDNtop, right, bxUPbtm,
    bgcolor = i_BPR ? color.new(cFVGbl, 90) : color(na),
    border_color = i_BPR ? color.new(cFVGbl, 65) : color(na),
    text_color = i_BPR ? color.new(cFVGbl, 65) : color(na),
    text_size = size.small,
    text = ‘BPR’
    ),
    true,
    close > bxUPbtm ? 1 : close < bxDNtop ? -1 : 0
    ))
    bBPR_UP.pop().box.delete()

    // Check for opposite box
    if bxDNbtm < bxUPtop and bxUPbtm < bxDNbtm then
    if left == bBPR_DN.get(0).box.get_left() then
    if bBPR_DN.get(0).active then
    bBPR_DN.get(0).box.set_right(right)
    else
    bBPR_DN.unshift(FVG.new(
    box.new(left, bxUPtop, right, bxDNbtm,
    bgcolor = i_BPR ? color.new(cFVGbr, 90) : color(na),
    border_color = i_BPR ? color.new(cFVGbr, 65) : color(na),
    text_color = i_BPR ? color.new(cFVGbr, 65) : color(na),
    text_size = size.small,
    text = ‘BPR’
    ),
    true,
    close > bxDNbtm ? 1 : close < bxUPtop ? -1 : 0
    ))
    bBPR_DN.pop().box.delete()
    end if
    end if
    end if

    // FVG’s breaks
    for i = 0 to min(bxBack, bFVG_UP.size() – 1) do
    getUPi = bFVG_UP.get(i)
    if getUPi.active then
    getUPi.box.set_right(bar_index + 8)
    if low < getUPi.box.get_top() and not i_BPR then
    getUPi.box.set_border_style(line.style_dashed)
    if low < getUPi.box.get_bottom() then
    if not i_BPR then
    getUPi.box.set_bgcolor(color.new(cFVGblBR, 95))
    getUPi.box.set_border_style(line.style_dotted)
    getUPi.box.set_right(bar_index)
    getUPi.active := false
    end if
    end if
    end for

    for i = 0 to min(bxBack, bFVG_DN.size() – 1) do
    getDNi = bFVG_DN.get(i)
    if getDNi.active then
    getDNi.box.set_right(bar_index + 8)
    if high > getDNi.box.get_bottom() and not i_BPR then
    getDNi.box.set_border_style(line.style_dashed)
    if high > getDNi.box.get_top() then
    if not i_BPR then
    getDNi.box.set_bgcolor(color.new(cFVGbrBR, 95))
    getDNi.box.set_border_style(line.style.dotted)
    getDNi.box.set_right(bar_index)
    getDNi.active := false
    end if
    end if
    end for

    if i_BPR then
    for i = 0 to min(bxBack, bBPR_UP.size() – 1) do
    getUPi = bBPR_UP.get(i)
    if getUPi.active then
    getUPi.box.set_right(bar_index + 8)
    switch getUPi.pos
    case -1:
    if high > getUPi.box.get_bottom() then
    getUPi.box.set_border_style(line.style_dashed)
    if high > getUPi.box.get_top() then
    getUPi.box.set_bgcolor(color.new(cFVGblBR, 95))
    getUPi.box.set_border_style(line.style.dotted)
    getUPi.box.set_right(bar_index)
    getUPi.active := false
    case 1:
    if low < getUPi.box.get_top() then
    getUPi.box.set_border_style(line.style_dashed)
    if low < getUPi.box.get_bottom() then
    getUPi.box.set_bgcolor(color.new(cFVGblBR, 95))
    getUPi.box.set_border_style(line.style.dotted)
    getUPi.box.set_right(bar_index)
    getUPi.active := false
    end switch
    end if
    end for

    for i = 0 to min(bxBack, bBPR_DN.size() – 1) do
    getDNi = bBPR_DN.get(i)
    if getDNi.active then
    getDNi.box.set_right(bar_index + 8)
    switch getDNi.pos
    case -1:
    if high > getDNi.box.get_bottom() then
    getDNi.box.set_border_style(line.style_dashed)
    if high > getDNi.box.get_top() then
    getDNi.box.set_bgcolor(color.new(cFVGbrBR, 95))
    getDNi.box.set_border_style(line.style.dotted)
    getDNi.box.set_right(bar_index)
    getDNi.active := false
    case 1:
    if low < getDNi.box.get_top() then
    getDNi.box.set_border_style(line.style_dashed)
    if low < getDNi.box.get_bottom() then
    getDNi.box.set_bgcolor(color.new(cFVGbrBR, 95))
    getDNi.box.set_border_style(line.style.dotted)
    getDNi.box.set_right(bar_index)
    getDNi.active := false
    end switch
    end if
    end for
    end if

    // NWOG/NDOG
    if barstate.isfirst then
    for i = 0 to maxNWOG – 1 do
    bl_NWOG.unshift(bx_ln.new(box(na), line(na)))
    end for

    for i = 0 to maxNDOG – 1 do
    bl_NDOG.unshift(bx_ln.new(box(na), line(na)))
    end for
    end if

    if dayofweek == dayofweek.friday then
    friCp := close
    friCi := n
    end if

    if ta.change(dayofweek) then
    if dayofweek == dayofweek.monday and iNWOG then
    monOp := open
    monOi := n
    bl_NWOG.unshift(bx_ln.new(
    box.new(
    friCi, math.max(friCp, monOp),
    monOi, math.min(friCp, monOp),
    bgcolor = color(na),
    border_color = cNWOG2,
    extend = extend.right
    ),
    line.new(
    monOi, math.avg(friCp, monOp),
    monOi + 1, math.avg(friCp, monOp),
    color = cNWOG1,
    style = line.style_dotted,
    extend = extend.right
    )
    ))
    bl = bl_NWOG.pop()
    bl.b.delete()
    bl.l.delete()
    end if

    if iNDOG then
    cuDOp := open
    cuDOi := n
    prDCp := close[1]
    prDCi := n – 1
    //
    bl_NDOG.unshift(bx_ln.new(
    box.new(
    prDCi, math.max(prDCp, cuDOp),
    cuDOi, math.min(prDCp, cuDOp),
    bgcolor = color(na),
    border_color = cNDOG2,
    extend = extend.right
    ),
    line.new(
    cuDOi, math.avg(prDCp, cuDOp),
    cuDOi + 1, math.avg(prDCp, cuDOp),
    color = cNDOG1,
    style = line.style_dotted,
    extend = extend.right
    )
    ))
    bl = bl_NDOG.pop()
    bl.b.delete()
    bl.l.delete()
    end if
    end if

    // Liquidity
    for i = 0 to b_liq_B.size() – 1 do
    x = b_liq_B.get(i)
    if not x.broken then
    x.bx.set_right(n + 3)
    x.ln.set_x2(n + 3)

    if not x.brokenTop then
    if close > x.bx.get_top() then
    x.brokenTop := true
    end if
    end if

    if not x.brokenBtm then
    if close > x.bx.get_bottom() then
    x.brokenBtm := true
    end if
    end if

    if x.brokenBtm then
    x.bx.set_bgcolor(color.new(cLIQ_B, 90))
    x.ln.delete()
    if x.brokenTop then
    x.broken := true
    x.bx.set_right(n)
    end if
    end if
    end if
    end for

    for i = 0 to b_liq_S.size() – 1 do
    x = b_liq_S.get(i)
    if not x.broken then
    x.bx.set_right(n + 3)
    x.ln.set_x2(n + 3)

    if not x.brokenTop then
    if close < x.bx.get_top() then
    x.brokenTop := true
    end if
    end if

    if not x.brokenBtm then
    if close < x.bx.get_bottom() then
    x.brokenBtm := true
    end if
    end if

    if x.brokenTop then
    x.bx.set_bgcolor(color.new(cLIQ_S, 90))
    x.ln.delete()
    if x.brokenBtm then
    x.broken := true
    x.bx.set_right(n)
    end if
    end if
    end if
    end for

    // Order Blocks
    [top, btm] = swings(length)

    if showOB and per then
    // Bullish Order Block
    if close > top.y and not top.crossed then
    top.crossed := true

    minima = max[1]
    maxima = min[1]
    loc = time[1]

    for i = 1 to (n – top.x) – 1 do
    minima := math.min(min[i], minima)
    maxima := minima == min[i] ? max[i] : maxima
    loc := minima == min[i] ? time[i] : loc
    end for

    bullish_ob.unshift(ob.new(maxima, minima, loc))
    end if

    if bullish_ob.size() > 0 then
    for i = bullish_ob.size() – 1 to 0 do
    element = bullish_ob.get(i)

    if not element.breaker then
    if math.min(close, open) < element.btm then
    element.breaker := true
    element.break_loc := time
    end if
    else
    if close > element.top then
    bullish_ob.remove(i)
    else if i < showBull and top.y < element.top and top.y > element.btm then
    blBrkConf := 1
    end if
    end if
    end for
    end if

    // Set label
    if blBrkConf > blBrkConf[1] and showLabels then
    label.new(top.x, top.y, ‘▼’, color = na,
    textcolor = bearCss.notransp(),
    style = label.style_label_down,
    size = size.tiny)
    end if
    end if

    if showOB and per then
    // Bearish Order Block
    if close < btm.y and not btm.crossed then
    btm.crossed := true

    minima = min[1]
    maxima = max[1]
    loc = time[1]

    for i = 1 to (n – btm.x) – 1 do
    maxima := math.max(max[i], maxima)
    minima := maxima == max[i] ? min[i] : minima
    loc := maxima == max[i] ? time[i] : loc
    end for

    bearish_ob.unshift(ob.new(maxima, minima, loc))
    end if

    if bearish_ob.size() > 0 then
    for i = bearish_ob.size() – 1 to 0 do
    element = bearish_ob.get(i)

    if not element.breaker then
    if math.max(close, open) > element.top then
    element.breaker := true
    element.break_loc := time
    end if
    else
    if close < element.btm then
    bearish_ob.remove(i)
    else if i < showBear and btm.y > element.btm and btm.y < element.top then
    brBrkConf := 1
    end if
    end if
    end for
    end if

    // Set label
    if brBrkConf > brBrkConf[1] and showLabels then
    label.new(btm.x, btm.y, ‘▲’, color = na,
    textcolor = bullCss.notransp(),
    style = label.style_label_up,
    size = size.tiny)
    end if
    end if

    //—————————————————————————–
    // Set Order Blocks
    //—————————————————————————–
    if barstate.islast and showOB then
    if a_bx_ln_lb.size() > 0 then
    for i = a_bx_ln_lb.size() – 1 to 0 do
    item = a_bx_ln_lb.remove(i)
    item.bx.delete()
    item.ln.delete()
    item.lb.delete()
    end for
    end if

    // Bullish
    if showBull > 0 then
    blSz = bullish_ob.size()
    if blSz > 0 then
    for i = 0 to math.min(showBull, bullish_ob.size()) – 1 do
    get_ob = bullish_ob.get(i)
    get_ob.display(bullCss, bullBrkCss, ‘bl’)
    end for
    end if
    end if

    // Bearish
    if showBear > 0 then
    brSz = bearish_ob.size()
    if brSz > 0 then
    for i = 0 to math.min(showBear, bearish_ob.size()) – 1 do
    get_ob = bearish_ob.get(i)
    get_ob.display(bearCss, bearBrkCss, ‘br’)
    end for
    end if
    end if
    end if

    //—————————————————————————–
    // Fibonacci
    //—————————————————————————–
    if barstate.islast then
    x1 = 0
    y1 = 0
    x2 = 0
    y2 = 0
    box up = na
    box dn = na

    switch iFib
    ‘FVG’ =>
    if bFVG_UP.size() > 0 and bFVG_DN.size() > 0 then
    up := bFVG_UP.get(0).box
    dn := bFVG_DN.get(0).box
    dnFirst = up.get_left() > dn.get_left()
    dnBottm = up.get_top() > dn.get_top()
    x1 := dnFirst ? dn.get_left() : up.get_left()
    x2 := dnFirst ? up.get_right() : dn.get_right()
    y1 := dnFirst ?
    dnBottm ? dn.get_bottom() : dn.get_top() :
    dnBottm ? up.get_top() : up.get_bottom()
    y2 := dnFirst ?
    dnBottm ? up.get_top() : up.get_bottom() :
    dnBottm ? dn.get_bottom() : dn.get_top()
    end if
    ‘BPR’ =>
    if bBPR_UP.size() > 0 and bBPR_DN.size() > 0 then
    up := bBPR_UP.get(0).box
    dn := bBPR_DN.get(0).box
    dnFirst = up.get_left() > dn.get_left()
    dnBottm = up.get_top() > dn.get_top()
    x1 := dnFirst ? dn.get_left() : up.get_left()
    x2 := dnFirst ? up.get_right() : dn.get_right()
    y1 := dnFirst ?
    dnBottm ? dn.get_bottom() : dn.get_top() :
    dnBottm ? up.get_top() : up.get_bottom()
    y2 := dnFirst ?
    dnBottm ? up.get_top() : up.get_bottom() :
    dnBottm ? dn.get_bottom() : dn.get_top()
    end if
    ‘OB’ =>
    oSz = a_bx_ln_lb.size()
    if oSz > 1 then
    xA = nz(
    a_bx_ln_lb.get(oSz – 1).ln.get_x1(),
    a_bx_ln_lb.get(oSz – 1).bx.get_left()
    )
    xB = nz(
    a_bx_ln_lb.get(oSz – 2).ln.get_x1(),
    a_bx_ln_lb.get(oSz – 2).bx.get_left()
    )
    AFirst = xB > xA
    //
    yAT = nz(
    a_bx_ln_lb.get(oSz – 1).ln.get_y1(),
    a_bx_ln_lb.get(oSz – 1).bx.get_top()
    )
    yAB = nz(
    a_bx_ln_lb.get(oSz – 1).ln.get_y1(),
    a_bx_ln_lb.get(oSz – 1).bx.get_bottom()
    )
    yBT = nz(
    a_bx_ln_lb.get(oSz – 2).ln.get_y1(),
    a_bx_ln_lb.get(oSz – 2).bx.get_top()
    )
    yBB = nz(
    a_bx_ln_lb.get(oSz – 2).ln.get_y1(),
    a_bx_ln_lb.get(oSz – 2).bx.get_bottom()
    )
    ABottom = yAB < yBB
    //
    x1 := AFirst ? xA : xB
    x2 := AFirst ? xB : xA
    y1 := AFirst ?
    ABottom ? yAB : yAT :
    ABottom ? yBT : yBB
    y2 := AFirst ?
    ABottom ? yBT : yBB :
    ABottom ? yAB : yAT
    end if
    ‘Liq’ =>
    if b_liq_B.size() > 0 and b_liq_S.size() > 0 then
    xA = nz(
    b_liq_B.get(0).ln.get_x1(),
    b_liq_B.get(0).bx.get_left()
    )
    xB = nz(
    b_liq_S.get(0).ln.get_x1(),
    b_liq_S.get(0).bx.get_left()
    )
    AFirst = xB > xA
    //
    yAT = nz(
    b_liq_B.get(0).ln.get_y1(),
    b_liq_B.get(0).bx.get_top()
    )
    yAB = nz(
    b_liq_B.get(0).ln.get_y1(),
    b_liq_B.get(0).bx.get_bottom()
    )
    yBT = nz(
    b_liq_S.get(0).ln.get_y1(),
    b_liq_S.get(0).bx.get_top()
    )
    yBB = nz(
    b_liq_S.get(0).ln.get_y1(),
    b_liq_S.get(0).bx.get_bottom()
    )
    ABottom = yAB < yBB
    //
    x1 := AFirst ? xA : xB
    x2 := AFirst ? xB : xA
    y1 := AFirst ?
    ABottom ? yAB : yAT :
    ABottom ? yBT : yBB
    y2 := AFirst ?
    ABottom ? yBT : yBB :
    ABottom ? yAB : yAT
    end if
    ‘VI’ =>
    if Vimbal.size() > 1 then
    AxA = Vimbal.get(1).l2.get_x1()
    AxB = Vimbal.get(1).l1.get_x1()
    BxA = Vimbal.get(0).l2.get_x1()
    BxB = Vimbal.get(0).l1.get_x1()
    AyA = Vimbal.get(1).l2.get_y1()
    AyB = Vimbal.get(1).l1.get_y1()
    ByA = Vimbal.get(0).l2.get_y1()
    ByB = Vimbal.get(0).l1.get_y1()
    ABt = math.min(ByA, ByB) > math.min(AyA, AyB)
    x1 := math.max(AxA, AxB)
    x2 := math.max(BxA, BxB)
    y1 := ABt ? math.min(AyA, AyB) : math.max(AyA, AyB)
    y2 := ABt ? math.max(ByA, ByB) : math.min(ByA, ByB)
    end if
    ‘NWOG’ =>
    if bl_NWOG.size() > 1 then
    up := bl_NWOG.get(0).b
    dn := bl_NWOG.get(1).b
    dnFirst = up.get_left() > dn.get_left()
    dnBottm = up.get_top() > dn.get_top()
    x1 := dnFirst ? dn.get_left() : up.get_left()
    x2 := dnFirst ? up.get_right() : dn.get_right()
    y1 := dnFirst ?
    dnBottm ? dn.get_bottom() : dn.get_top() :
    dnBottm ? up.get_top() : up.get_bottom()
    y2 := dnFirst ?
    dnBottm ? up.get_top() : up.get_bottom() :
    dnBottm ? dn.get_bottom() : dn.get_top()
    end if
    //
    if iFib != ‘NONE’ then
    rt = math.max(x1, x2)
    lt = math.min(x1, x2)
    tp = math.max(y1, y2)
    bt = math.min(y1, y2)
    _0 = rt == x1 ? y1 : y2
    _1 = rt == x1 ? y2 : y1
    //
    df = _1 – _0
    m0236 = df * 0.236
    m0382 = df * 0.382
    m0500 = df * 0.500
    m0618 = df * 0.618
    m0786 = df * 0.786
    m1618 = df * 1.618
    //
    _diag.setLine(x1, y1, x2, y2)
    _vert.setLine(rt, _0, rt, _0 + m1618)
    _zero.setLine(rt, _0, rt + plus, _0)
    _0236.setLine(rt, _0 + m0236, rt + plus, _0 + m0236)
    _0382.setLine(rt, _0 + m0382, rt + plus, _0 + m0382)
    _0500.setLine(rt, _0 + m0500, rt + plus, _0 + m0500)
    _0618.setLine(rt, _0 + m0618, rt + plus, _0 + m0618)
    _0786.setLine(rt, _0 + m0786, rt + plus, _0 + m0786)
    _one_.setLine(rt, _1, rt + plus, _1)
    _1618.setLine(rt, _0 + m1618, rt + plus, _0 + m1618)
    end if
    end if

    //—————————————————————————–
    // Displacement
    //—————————————————————————–
    if sDispl then
    if per then
    if L_bodyUP then
    plotShape(low, “Displacement UP”, shape.labelup, color.lime, location.belowbar)
    end if
    end if

    if per then
    if L_bodyDN then
    plotShape(high, “Displacement DN”, shape.labeldown, color.red, location.abovebar)
    end if
    end if
    end if

    //—————————————————————————–
    // Background – Killzones
    //—————————————————————————–
    if per then
    bgcolor(ny ? nyCss : na, editable = false)
    bgcolor(ldn_open ? ldnoCss : na, editable = false)
    bgcolor(ldn_close ? ldncCss : na, editable = false)
    bgcolor(asian ? asiaCss : na, editable = false)
    end if

    return

    #238573

    Bonjour Le code que vous essayez de saisir dans Prorealtime est mélangé avec un autre langage de programmation. Probablement une vue commerciale. Il y a trop d'erreurs. Ce que vous pouvez faire, c'est demander la traduction du code original via le lien suivant : https://www.prorealcode.com/free-code-conversion/ Fournissez des images de l'indicateur et toutes les informations que vous jugez pertinentes pour faciliter la traduction.

Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login