Indicateur WBR de Flux Charts
Forums › ProRealTime forum Français › Support ProBuilder › Indicateur WBR de Flux Charts
- This topic has 2 replies, 2 voices, and was last updated 1 day ago by
bertrandpinoy.
-
-
10/11/2025 at 9:43 AM #252468
bonjour a tous, j ai visionné la video jointe de Flux Charts et j ai commencé le travail pour créer l indicateur compatible chez nous. Mais je ne parviens pas a terminer. Je joins mon travail si un passionné veux aider, cordialement. https://www.youtube.com/watch?v=8XpPaTWhnLA&t=129s
// Wick to Body Ratio Trend Forecast
// Traduit et adapté pour ProRealTime par Grok (basé sur Flux Charts)
// Version 1.8.2 – 10:45 AM CEST, 11 Oct 2025 – Correction ligne 137// PARAMÈTRES
maxMatches = 9 // Nombre max de matchs (fixe à 9 pour tester)
loopbackPeriod = 200 // Réduit pour éviter surcharge
toleranceRatio = 0.1 // Tolérance pour les matchs de ratio
forecastLength = 15 // Nombre de bougies futures à prévoir// Variables globales
ratioActuel = 0
matchRatio0 = 0
matchRatio1 = 0
matchRatio2 = 0
matchRatio3 = 0
matchRatio4 = 0
matchRatio5 = 0
matchRatio6 = 0
matchRatio7 = 0
matchRatio8 = 0 // 9 variables
matchDebut0 = 0
matchDebut1 = 0
matchDebut2 = 0
matchDebut3 = 0
matchDebut4 = 0
matchDebut5 = 0
matchDebut6 = 0
matchDebut7 = 0
matchDebut8 = 0 // 9 variables
nombreMatches = 0
deviationMouv = 0
couleurLigne = 0 // 0 pour rouge (faible dev), 1 pour bleu (haute dev)// CALCUL DU RATIO WICK-TO-BODY
bodyCandle = abs(Close – Open)
totalWick = (High – Low) – bodyCandle
IF bodyCandle > 0 THEN
ratioActuel = totalWick / bodyCandle
ELSE
ratioActuel = 0 // Éviter division par zéro (doji)
ENDIF// RECHERCHE DE MATCHS HISTORIQUES (sur la dernière barre close)
IF BarIndex > loopbackPeriod THEN
nombreMatches = 0
FOR i = 1 TO loopbackPeriod DO
IF i < BarIndex THEN
bodyHist = abs(Close[i] – Open[i])
totalWickHist = (High[i] – Low[i]) – bodyHist
IF bodyHist > 0 THEN
ratioHist = totalWickHist / bodyHist
tolAdapt = toleranceRatio
IF nombreMatches < 3 AND toleranceRatio < 0.3 THEN
tolAdapt = toleranceRatio + 0.05
ENDIF
IF abs(ratioHist – ratioActuel) <= tolAdapt AND nombreMatches < maxMatches THEN
IF nombreMatches = 0 THEN
matchRatio0 = ratioHist
ELSE
IF nombreMatches = 1 THEN
matchRatio1 = ratioHist
ELSE
IF nombreMatches = 2 THEN
matchRatio2 = ratioHist
ELSE
IF nombreMatches = 3 THEN
matchRatio3 = ratioHist
ELSE
IF nombreMatches = 4 THEN
matchRatio4 = ratioHist
ELSE
IF nombreMatches = 5 THEN
matchRatio5 = ratioHist
ELSE
IF nombreMatches = 6 THEN
matchRatio6 = ratioHist
ELSE
IF nombreMatches = 7 THEN
matchRatio7 = ratioHist
ELSE
IF nombreMatches = 8 THEN
matchRatio8 = ratioHist
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIFIF nombreMatches = 0 THEN
matchDebut0 = Close[i]
ELSE
IF nombreMatches = 1 THEN
matchDebut1 = Close[i]
ELSE
IF nombreMatches = 2 THEN
matchDebut2 = Close[i]
ELSE
IF nombreMatches = 3 THEN
matchDebut3 = Close[i]
ELSE
IF nombreMatches = 4 THEN
matchDebut4 = Close[i]
ELSE
IF nombreMatches = 5 THEN
matchDebut5 = Close[i]
ELSE
IF nombreMatches = 6 THEN
matchDebut6 = Close[i]
ELSE
IF nombreMatches = 7 THEN
matchDebut7 = Close[i]
ELSE
IF nombreMatches = 8 THEN
matchDebut8 = Close[i]
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
nombreMatches = nombreMatches + 1
ENDIF
ENDIF // Fermeture IF bodyHist > 0
ENDIF
NEXT// Calcul de la prévision si assez de matchs
IF nombreMatches >= 3 THEN
DIM forecastValues(0 TO 14) // Taille fixe à 15 éléments (0 à 14)
FOR offset = 1 TO forecastLength DO
sommeMouvs = 0
FOR j = 0 TO nombreMatches – 1 DO
IF BarIndex – i – offset > 0 THEN
IF j = 0 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 1 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 2 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 3 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 4 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 5 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 6 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 7 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ELSE
IF j = 8 THEN
mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
sommeMouvs = sommeMouvs + mouvement
ENDIF
NEXT
IF nombreMatches > 0 THEN
forecastValues[offset-1] = Close + (sommeMouvs / nombreMatches) * Close / 100
ENDIF
NEXT// Approximation simple de la déviation
deviationMouv = 0
FOR j = 0 TO nombreMatches – 1 DO
IF j = 0 THEN
mouvement = (Close[BarIndex – 1] – matchDebut0) / matchDebut0 * 100
ELSE
IF j = 1 THEN
mouvement = (Close[BarIndex – 1] – matchDebut1) / matchDebut1 * 100
ELSE
IF j = 2 THEN
mouvement = (Close[BarIndex – 1] – matchDebut2) / matchDebut2 * 100
ELSE
IF j = 3 THEN
mouvement = (Close[BarIndex – 1] – matchDebut3) / matchDebut3 * 100
ELSE
IF j = 4 THEN
mouvement = (Close[BarIndex – 1] – matchDebut4) / matchDebut4 * 100
ELSE
IF j = 5 THEN
mouvement = (Close[BarIndex – 1] – matchDebut5) / matchDebut5 * 100
ELSE
IF j = 6 THEN
mouvement = (Close[BarIndex – 1] – matchDebut6) / matchDebut6 * 100
ELSE
IF j = 7 THEN
mouvement = (Close[BarIndex – 1] – matchDebut7) / matchDebut7 * 100
ELSE
IF j = 8 THEN
mouvement = (Close[BarIndex – 1] – matchDebut8) / matchDebut8 * 100
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
deviationMouv = deviationMouv + abs(mouvement – (sommeMouvs / nombreMatches))
NEXT
IF nombreMatches > 0 THEN
deviationMouv = deviationMouv / nombreMatches
ENDIF// Couleur : faible dev -> rouge, haute -> bleu
IF deviationMouv < 2 THEN
couleurLigne = 0 // Rouge
ELSE
couleurLigne = 1 // Bleu
ENDIF// TRACÉ DE LA LIGNE DE PRÉVISION
FOR k = 1 TO forecastLength DO
IF Time > LastBarTime THEN
IF couleurLigne = 0 THEN
DRAWLINE(LastBarIndex + k, forecastValues[k-1], LastBarIndex + forecastLength, forecastValues[forecastLength-1]) COLOURED(RGB(255,0,0)) STYLE(line)
ELSE
DRAWLINE(LastBarIndex + k, forecastValues[k-1], LastBarIndex + forecastLength, forecastValues[forecastLength-1]) COLOURED(RGB(0,0,255)) STYLE(line)
ENDIF
ENDIF
NEXT
ENDIF // Fermeture IF nombreMatches >= 3
ENDIF // Fermeture IF BarIndex > loopbackPeriod// Affichage du ratio actuel
RETURN ratioActuel AS “WBR Ratio”10/14/2025 at 12:38 PM #252592voici:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226//-------------------------------------------////PRC_Wick to Body Ratio Trend Forecast by fluxchart//version = 0//14.10.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------------//// --- ALGORITHM SETTINGS ---// Number of candles to look backloopback = 400// Bar length of the forecast linesforecast = 10// Ratio Type to use: 1=General, 2=Top Wick, 3=Bottom Wick, 4=BodyratioType = 1// If 1, only candles of the same direction (bullish/bearish) are compareddirectionBias = 1 // 1=true, 0=false// Initial Accuracy: 1=High, 2=Medium, 3=LowdefaultAccuracy = 2// --- FORECAST LINES ---// High confidence color (R,G,B values)deviationHighR = 255deviationHighG = 0deviationHighB = 0// Low confidence color (R,G,B values)deviationLowR = 0deviationLowG = 0deviationLowB = 255// --- PAST TRENDS ---// 1 = Draws a box around matching past trendstrendSquare = 1// 1 = Labels the ratios of matching candlestrendSquareLabels = 1// --- OTHER ---// 1 = Displays warning messages on the chartdisplayLogs = 1// --- VARIABLE INITIALIZATION ---ONCE accuracy = 0.02IF defaultAccuracy = 1 THENaccuracy = 0.01ELSIF defaultAccuracy = 3 THENaccuracy = 0.04ENDIFONCE ratioNotFindable = 0ONCE lastBar = 0ONCE matchesFound = 0ONCE loopBreaker = 0// --- CANDLE RATIO CALCULATION ---myRatio = 0sign = 0IF (close - open) > 0 THENsign = 1ELSIF (close - open) < 0 THENsign = -1ENDIF// General RatioIF ratioType = 1 THENIF ABS(close - open) > 0 THENmyRatio = ((ABS(low - high) - ABS(close - open)) / ABS(close - open)) * signELSEmyRatio = 0ENDIF// Top WickELSIF ratioType = 2 THENIF ABS(close - open) > 0 THENmyRatio = ((MAX(close, open) - high) / ABS(close - open)) * signELSEmyRatio = 0ENDIF// Bottom WickELSIF ratioType = 3 THENIF ABS(close - open) > 0 THENmyRatio = ((MIN(close, open) - low) / ABS(close - open)) * signELSEmyRatio = 0ENDIF// Body RatioELSIF ratioType = 4 THENIF ABS(high - low) > 0 THENmyRatio = (ABS(close - open) / ABS(high - low)) * signELSEmyRatio = 0ENDIFENDIF// --- MAIN LOGIC (RUNS ON THE LAST BAR) ---IF ISLASTBARUPDATE THEN// Clear arrays for new calculationUNSET($sumArray)UNSET($sumOfSquaresArray)// Label for the current candle's ratioIF trendSquareLabels = 1 THENratio = ROUND(myRatio[1]*100)/100DRAWTEXT("Ratio: #ratio#", barindex[1], high[1] + (high[1]-low[1])*0.5) COLOURED(0,0,255)ENDIF// Loop to adjust accuracy and find matchesmatchesFound = 0loopBreaker = 0WHILE loopBreaker < 20 DO // Safety loop to prevent infinite loopsmatchesFound = 0lastBar = 0// Reset accumulation arraysFOR f = 0 TO forecast - 1 DO$sumArray[f] = 0$sumOfSquaresArray[f] = 0NEXT// Main loop to search through historical dataFOR i = forecast + lastBar TO (loopback + forecast) DObarsDifference = ABS(ABS(myRatio[i]) - ABS(myRatio[1]))ratioSignI = 0IF myRatio[i] > 0 THENratioSignI = 1ELSIF myRatio[i] < 0 THENratioSignI = -1ENDIFratioSignCurrent = 0IF myRatio[1] > 0 THENratioSignCurrent = 1ELSIF myRatio[1] < 0 THENratioSignCurrent = -1ENDIFratioDirectionMatch = (ratioSignI = ratioSignCurrent)IF (barsDifference <= accuracy AND ratioDirectionMatch) OR (barsDifference <= accuracy AND directionBias = 0) THENmatchesFound = matchesFound + 1// Accumulate values for the forecastFOR y = 0 TO forecast - 1 DOcandleValue = close[i - y - 1] - close[i]$sumArray[y] = $sumArray[y] + candleValue$sumOfSquaresArray[y] = $sumOfSquaresArray[y] + POW(candleValue, 2)NEXT// Draw boxes and labels on past matchesIF trendSquare = 1 OR trendSquareLabels = 1 THENmytop = highest[forecast](high[i-1])mybottom = lowest[forecast](low[i-1])IF trendSquare = 1 THENDRAWRECTANGLE(barindex[i], mytop, barindex[i - forecast], mybottom) COLOURED(192,192,192)fillcolor(192,192,192,50)ENDIFIF trendSquareLabels = 1 THENdirectionColorR = 255directionColorG = 0IF myRatio[i] > 0 THENdirectionColorR = 0directionColorG = 255ENDIFratio = ROUND(myRatio[i]*100)/100DRAWTEXT("Match: #ratio#", barindex[i], high[i] + (high[i]-low[i])*0.5) COLOURED(directionColorR, directionColorG, 0)ENDIFENDIF// Update to avoid repeating the same candle (optimization)lastBar = iENDIFNEXT// Accuracy adjustment logicIF matchesFound < 5 THENaccuracy = accuracy + 0.01ELSIF matchesFound > 15 THENaccuracy = accuracy - 0.005ELSEratioNotFindable = 0BREAK // Exit the WHILE loopENDIFIF accuracy > 0.1 AND matchesFound = 0 THENratioNotFindable = 1IF displayLogs = 1 THENDRAWTEXT("WARNING: No matches found.", barindex - 50, high) ANCHOR(TOPLEFT, INDEX, YSHIFT) COLOURED(255,165,0)ENDIFBREAKENDIFloopBreaker = loopBreaker + 1WEND// --- DRAWING THE FORECAST LINE ---IF ratioNotFindable = 0 AND matchesFound > 0 THENdeviation = (ArrayMax($sumArray)/matchesFound - ArrayMin($sumArray)/matchesFound) / 2FOR i = 0 TO forecast - 2 DOavgCurrent = $sumArray[i] / matchesFoundavgNext = $sumArray[i+1] / matchesFound// Calculate standard deviation for colorsumSqCurrent = $sumOfSquaresArray[i]stdevCurrent = SQRT((sumSqCurrent / matchesFound) - POW(avgCurrent, 2))// Simulate gradient colorlineR = deviationLowRlineG = deviationLowGlineB = deviationLowBIF stdevCurrent > deviation / 2 THENlineR = deviationHighRlineG = deviationHighGlineB = deviationHighBENDIF// Draw a segment of the forecast lineDRAWSEGMENT(barindex + i + 1, close[1] + avgCurrent, barindex + i + 2, close[1] + avgNext) STYLE(Line, 2) COLOURED(lineR, lineG, lineB)NEXTENDIFENDIFRETURN10/14/2025 at 2:18 PM #252599Vous êtes vraiment très fort! merci beaucoup.
-
AuthorPosts
Find exclusive trading pro-tools on