Conversion code ICT BPR pour ProRealTime

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

    Bonjour,

    Serait-il possible de convertir le code joint en langage ProBuilder pour ProRealTime.

    Je joins de plus le lien original afin d’avoir une vue d’ensemble sur ce que devrait faire le code!

    Merci

    https://fr.tradingview.com/script/zPbYfcE8-ICT-Balance-Price-Range-UAlgo/

    // This Pine Script™ code is subject to the terms of the Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
    // © UAlgo
    //@version=5
    indicator("ICT Balance Price Range [UAlgo]", "ICT Balance Price Range [UAlgo]", overlay=true)
    
    // Input parameters
    lookback_bars = input(12, "Bars to Consider", tooltip="Number of bars to consider for BPR conditions",group = "ICT Balance Price Range [UAlgo] Settings")
    threshold = input.float(0, step=0.25, title="Threshold for BPR", tooltip="Minimum range required for a valid BPR",group = "ICT Balance Price Range [UAlgo] Settings")
    remove_old_bpr = input(false, "Remove Old BPR", tooltip="Remove invalidated BPRs automatically",group = "ICT Balance Price Range [UAlgo] Settings")
    bear_color = input(color.new(color.rgb(255, 0, 0), 70), title="Bearish/Bullish Box Color", inline="color",group = "ICT Balance Price Range [UAlgo] Settings")
    bull_color = input(color.new(color.rgb(0, 128, 0), 70), title=" ", inline="color",group = "ICT Balance Price Range [UAlgo] Settings")
    
    // Variables
    var box bearish_box = na
    var box bullish_box = na
    
    // Functions to check FVG conditions
    bear_fvg = high < low[2] and close[1] < low[2]
    bull_fvg = low > high[2] and close[1] > high[2] 
    
    // Bullish BPR logic
    bull_since = ta.barssince(bear_fvg)
    bull_cond_1 = bull_fvg and bull_since <= lookback_bars
    combined_low_bull = bull_cond_1 ? math.max(high[bull_since], high[2]) : na
    combined_high_bull = bull_cond_1 ? math.min(low[bull_since + 2], low) : na
    bull_result = bull_cond_1 and (combined_high_bull - combined_low_bull >= threshold)
    
    // Create or update bullish box
    if bull_result
        if remove_old_bpr and not na(bullish_box)
            box.delete(bullish_box)
        bullish_box := box.new(bar_index - bull_since - 1, combined_high_bull, bar_index + 1, combined_low_bull, border_color=bull_color, border_width=1, bgcolor=bull_color)
    
    // Alert for bullish BPR
    alertcondition(bull_result, "Bullish Alert", "New Bullish BPR")
    
    // Update bullish box position if necessary
    if not na(bullish_box)
        if low > box.get_bottom(bullish_box)
            box.set_right(bullish_box, bar_index + 1)
        else
            bullish_box := na
    
    // Bearish BPR logic
    bear_since = ta.barssince(bull_fvg)
    bear_cond_1 = bear_fvg and bear_since <= lookback_bars
    combined_low_bear = bear_cond_1 ? math.max(high[bear_since + 2], high) : na
    combined_high_bear = bear_cond_1 ? math.min(low[bear_since], low[2]) : na
    bear_result = bear_cond_1 and (combined_high_bear - combined_low_bear >= threshold)
    
    // Create or update bearish box
    if bear_result
        if remove_old_bpr and not na(bearish_box)
            box.delete(bearish_box)
        bearish_box := box.new(bar_index - bear_since - 1, combined_high_bear, bar_index + 1, combined_low_bear, border_color=bear_color, border_width=1, bgcolor=bear_color)
    
    // Alert for bearish BPR
    alertcondition(bear_result, "Bearish Alert", "New Bearish BPR")
    
    // Update bearish box position if necessary
    if not na(bearish_box)
        if high < box.get_top(bearish_box)
            box.set_right(bearish_box, bar_index + 1)
        else
            bearish_box := na
    
    #248635 quote
    Iván González
    Moderator
    Master

    Bonjour. Vous avez ici :

    // -------------------------------------------------------------------------
    // PRC_ICT Balance Price Range [UAlgo]
    //version = 0
    //02.07.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    // -------------------------------------------------------------------------
    DEFPARAM DRAWONLASTBARONLY = true
    lookbackBars = 12 
    threshold = 0.0 
    
    bearFVG = (high < low[2] AND close[1] < low[2])
    bullFVG = (low > high[2] AND close[1] > high[2])
    
    bullSince = BarsSince(bearFVG)
    bearSince = BarsSince(bullFVG)
    
    bullCond1 = (bullFVG AND bullSince <= lookbackBars)
    
    IF bullCond1 THEN
    combinedLowBull = MAX(high[max(0,bullSince)], high[2])
    combinedHighBull = MIN(low[max(0,bullSince) + 2], low)
        
    IF (combinedHighBull - combinedLowBull >= threshold) THEN
    
    $bullBoxLeft[bullBoxCount+1] = barindex - bullSince - 1
    $bullBoxTop[bullBoxCount+1] = combinedHighBull
    $bullBoxRight[bullBoxCount+1] = barindex + 1
    $bullBoxBottom[bullBoxCount+1] = combinedLowBull
    $bullBoxState[bullBoxCount+1] = 1
    bullBoxCount = bullBoxCount + 1
    ENDIF
    ENDIF
    
    if barindex > $bullBoxLeft[bullBoxCount] and $bullBoxState[bullBoxCount] = 1 then
    if low > $bullBoxBottom[bullBoxCount] then
    $bullBoxRight[bullBoxCount]=barindex + 1
    else
    $bullBoxState[bullBoxCount] = -1
    endif
    endif
    
    bearCond1 = (bearFVG AND bearSince <= lookbackBars)
    
    IF bearCond1 THEN
    combinedLowBear = MAX(high[max(0,bearSince) + 2], high)
    combinedHighBear = MIN(low[max(0,bearSince)], low[2])
        
    IF (combinedHighBear - combinedLowBear >= threshold) THEN
    
    $bearBoxLeft[bearBoxCount+1] = barindex - bearSince - 1
    $bearBoxTop[bearBoxCount+1] = combinedHighBear
    $bearBoxRight[bearBoxCount+1] = barindex + 1
    $bearBoxBottom[bearBoxCount+1] = combinedLowBear
    $bearBoxState[bearBoxCount+1] = 1
    bearBoxCount = bearBoxCount + 1
    ENDIF
    ENDIF
    
    if barindex > $bearBoxLeft[bearBoxCount] and $bearBoxState[bearBoxCount] = 1 then
    if high < $bearBoxTop[bearBoxCount] then
    $bearBoxRight[bearBoxCount]=barindex + 1
    else
    $bearBoxState[bearBoxCount] = -1
    endif
    endif
    
    IF ISLASTBARUPDATE THEN
    
    FOR i = 1 TO bearBoxCount DO
    DRAWRECTANGLE($bearBoxLeft[i], $bearBoxTop[i], $bearBoxRight[i], $bearBoxBottom[i]) BORDERCOLOR(255,0,0) COLOURED(255,0,0,35)
    NEXT
        
    FOR i = 1 TO bullBoxCount  DO
    DRAWRECTANGLE($bullBoxLeft[i], $bullBoxTop[i], $bullBoxRight[i], $bullBoxBottom[i]) BORDERCOLOR(0,128,0) COLOURED(0,128,0,35)
    NEXT
    ENDIF
    
    RETURN
    Alai-n thanked this post
    #248647 quote
    Alai-n
    Participant
    Veteran

    Merci Iván

    #254422 quote
    bertrandpinoy
    Participant
    Veteran

    Malgré l ajout de “defparam calculateonlastbars=2000” l indicateur ne s’applique pas au graph. voir copie écran.

    beug.jpg beug.jpg
    #254495 quote
    Iván González
    Moderator
    Master

    Je ne sais pas quoi vous dire. Je l'ai chargée à 200 000 bougies et elle fonctionne parfaitement.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Conversion code ICT BPR pour ProRealTime


ProBuilder : Indicateurs & Outils Personnalisés

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

This topic contains 4 replies,
has 3 voices, and was last updated by Iván González
3 months, 1 week ago.

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