//@version=6 indicator("ROROFX INVEST", overlay=true) // === Paramètres de configuration === // Paramètres pour les nuages de Fibonacci lengthHigh = input(20, title="Longueur pour les points hauts (Fibonacci)") lengthLow = input(20, title="Longueur pour les points bas (Fibonacci)") // Paramètres pour les moyennes mobiles smaLength = input(7, title="Longueur de la SMA/EMA") timeframe_5min = input("5", title="Unité de temps pour 5 minutes") timeframe_30min = input("30", title="Unité de temps pour 30 minutes") timeframe_4h = input("240", title="Unité de temps pour 4 heures") timeframe_daily = input("D", title="Unité de temps pour Daily") timeframe_weekly = input("W", title="Unité de temps pour Weekly") // Paramètres pour les FVG showFVG = input.bool(true, title="Afficher les FVG") maxFVG = input.int(100, title="Nombre maximum de FVG à afficher", minval=1, maxval=200) fvgDisplayBars = input.int(10, title="Nombre minimum de barres pour afficher les FVG", minval=1, maxval=100) colorFVGUp = input.color(color.new(color.green, 80), title="Couleur FVG Haussier") colorFVGDown = input.color(color.new(color.red, 80), title="Couleur FVG Baissier") fvgFillThreshold = input.float(0.5, title="Seuil de comblement des FVG (en %)", minval=0.0, maxval=1.0, step=0.1) fvgMinGap = input.float(5.0, title="Écart minimum du FVG (en points)", minval=0.0, step=0.1) // === Déterminer la tendance avec deux EMAs === emaFast = ta.ema(close, 7) // EMA rapide (7 périodes) emaSlow = ta.ema(close, 21) // EMA lente (21 périodes) trendUp = emaFast > emaSlow // Tendance haussière si EMA rapide > EMA lente trendDown = emaFast < emaSlow // Tendance baissière si EMA rapide < EMA lente // Définir les couleurs des nuages de Fibonacci en fonction de la tendance colorFib1 = trendUp ? color.new(color.green, 80) : trendDown ? color.new(color.red, 80) : color.new(color.blue, 80) colorFib2 = trendUp ? color.new(color.green, 80) : trendDown ? color.new(color.red, 80) : color.new(color.green, 80) // === Calcul des nuages de Fibonacci === // Calcul des points hauts et bas highestHigh = ta.highest(high, lengthHigh) lowestLow = ta.lowest(low, lengthLow) // Vérification pour éviter les NaN validHighLow = not na(highestHigh) and not na(lowestLow) priceRange = validHighLow ? (highestHigh - lowestLow) : na validRange = priceRange > 0 // Calcul des niveaux de Fibonacci fib382 = validRange ? (lowestLow + 0.382 * priceRange) : na fib50 = validRange ? (lowestLow + 0.50 * priceRange) : na fib618 = validRange ? (lowestLow + 0.618 * priceRange) : na // Tracer le nuage de Fibonacci plotFib382 = plot(fib382, color=colorFib1, title="Fibonacci 0.382", linewidth=1, style=plot.style_stepline) plotFib50 = plot(fib50, color=colorFib1, title="Fibonacci 0.50", linewidth=1, style=plot.style_stepline) plotFib618 = plot(fib618, color=colorFib2, title="Fibonacci 0.618", linewidth=1, style=plot.style_stepline) fill(plotFib382, plotFib50, color=colorFib1, title="Nuage 0.382 - 0.50") fill(plotFib50, plotFib618, color=colorFib2, title="Nuage 0.50 - 0.618") // === Calcul des moyennes mobiles multi-timeframe === // Calcul de la SMA sur l'unité de temps 1 minute sma_1min = ta.sma(close, smaLength) // Calcul des EMA sur les unités de temps supérieures avec effet "escalier" ema_5min = request.security(syminfo.tickerid, timeframe_5min, ta.ema(close, smaLength), lookahead=barmerge.lookahead_on) ema_30min = request.security(syminfo.tickerid, timeframe_30min, ta.ema(close, smaLength), lookahead=barmerge.lookahead_on) ema_4h = request.security(syminfo.tickerid, timeframe_4h, ta.ema(close, smaLength), lookahead=barmerge.lookahead_on) ema_daily = request.security(syminfo.tickerid, timeframe_daily, ta.ema(close, smaLength), lookahead=barmerge.lookahead_on) ema_weekly = request.security(syminfo.tickerid, timeframe_weekly, ta.ema(close, smaLength), lookahead=barmerge.lookahead_on) // === Tracé des moyennes mobiles === plot(sma_1min, color=color.orange, linewidth=2, title="SMA 7 - 1min") plot(ema_5min, color=color.blue, linewidth=2, title="EMA 7 - 5min") plot(ema_30min, color=color.red, linewidth=2, title="EMA 7 - 30min") plot(ema_4h, color=color.green, linewidth=2, title="EMA 7 - 4H") plot(ema_daily, color=color.yellow, linewidth=2, title="EMA 7 - Daily") plot(ema_weekly, color=color.purple, linewidth=2, title="EMA 7 - Weekly") // === Tracé de l'ouverture journalière === daily_open = request.security(syminfo.tickerid, timeframe_daily, open, lookahead=barmerge.lookahead_on) plot(daily_open, color=color.white, linewidth=1, title="Daily Open", style=plot.style_circles) // === Détection et affichage des FVG === var box[] fvgBoxes = array.new_box(0) var float[] fvgTop = array.new_float(0) var float[] fvgBottom = array.new_float(0) var bool[] fvgType = array.new_bool(0) // true = haussier, false = baissier var int[] fvgBarIndex = array.new_int(0) // Pour stocker l'index de la barre où le FVG est détecté var bool[] fvgFilled = array.new_bool(0) // Pour marquer si le FVG a été comblé if showFVG // Détection des FVG haussiers (simplifiée) if low > high[2] fvg_high = low fvg_low = high[2] fvg_height = fvg_high - fvg_low if fvg_height >= fvgMinGap array.push(fvgTop, fvg_high) array.push(fvgBottom, fvg_low) array.push(fvgType, true) array.push(fvgBarIndex, bar_index) array.push(fvgFilled, false) // Message de débogage log.info("FVG Haussier détecté à la barre " + str.tostring(bar_index) + ": Haut=" + str.tostring(fvg_high) + ", Bas=" + str.tostring(fvg_low) + ", Hauteur=" + str.tostring(fvg_height)) // Détection des FVG baissiers (simplifiée) if high < low[2] fvg_high = low[2] fvg_low = high fvg_height = fvg_high - fvg_low if fvg_height >= fvgMinGap array.push(fvgTop, fvg_high) array.push(fvgBottom, fvg_low) array.push(fvgType, false) array.push(fvgBarIndex, bar_index) array.push(fvgFilled, false) // Message de débogage log.info("FVG Baissier détecté à la barre " + str.tostring(bar_index) + ": Haut=" + str.tostring(fvg_high) + ", Bas=" + str.tostring(fvg_low) + ", Hauteur=" + str.tostring(fvg_height)) // Limiter le nombre de FVG if array.size(fvgTop) > maxFVG array.shift(fvgTop) array.shift(fvgBottom) array.shift(fvgType) array.shift(fvgBarIndex) array.shift(fvgFilled) // Vérifier si un FVG est comblé à 50% ou trop ancien et le supprimer if array.size(fvgTop) > 0 for i = array.size(fvgTop) - 1 to 0 by 1 top = array.get(fvgTop, i) bottom = array.get(fvgBottom, i) isUp = array.get(fvgType, i) startBar = array.get(fvgBarIndex, i) filled = array.get(fvgFilled, i) // Calculer la hauteur du FVG fvgHeight = top - bottom // Seuil de comblement à 50% if not filled if isUp // Pour un FVG haussier, comblé à 50% si le prix descend à 50% de la hauteur à partir du haut fillLevel = top - (fvgHeight * fvgFillThreshold) if low <= fillLevel array.set(fvgFilled, i, true) log.info("FVG Haussier comblé à 50% à la barre " + str.tostring(bar_index) + ": fillLevel=" + str.tostring(fillLevel) + ", low=" + str.tostring(low)) else // Pour un FVG baissier, comblé à 50% si le prix monte à 50% de la hauteur à partir du bas fillLevel = bottom + (fvgHeight * fvgFillThreshold) if high >= fillLevel array.set(fvgFilled, i, true) log.info("FVG Baissier comblé à 50% à la barre " + str.tostring(bar_index) + ": fillLevel=" + str.tostring(fillLevel) + ", high=" + str.tostring(high)) // Supprimer si comblé ou trop ancien (plus de 500 barres dans le passé) if filled or (bar_index - startBar) > 500 array.remove(fvgTop, i) array.remove(fvgBottom, i) array.remove(fvgType, i) array.remove(fvgBarIndex, i) array.remove(fvgFilled, i) // Supprimer les anciens rectangles et redessiner if array.size(fvgBoxes) > 0 for i = 0 to array.size(fvgBoxes) - 1 box.delete(array.get(fvgBoxes, i)) array.clear(fvgBoxes) // Dessiner les rectangles pour chaque FVG if array.size(fvgTop) > 0 for i = 0 to array.size(fvgTop) - 1 top = array.get(fvgTop, i) bottom = array.get(fvgBottom, i) isUp = array.get(fvgType, i) startBar = array.get(fvgBarIndex, i) // Calculer endBar : s'étend jusqu'à la barre actuelle ou au minimum fvgDisplayBars endBarCalc = startBar + fvgDisplayBars endBar = math.max(endBarCalc, bar_index) // S'étend jusqu'à la barre actuelle // Dessiner le rectangle en utilisant xloc.bar_index, sans bordure, avec texte moins visible newBox = box.new(left=startBar, top=top, right=endBar, bottom=bottom, bgcolor=isUp ? colorFVGUp : colorFVGDown, border_color=na, xloc=xloc.bar_index, text="FVG", text_color=color.new(color.white, 90), text_size=size.normal, text_halign=text.align_center, text_valign=text.align_center) array.push(fvgBoxes, newBox)