// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Trading Evolution — https://tradingevolution.site // Indicateur Trading Evolution v2 : tendance (trend cloud EMA), structure de marché (HH/HL/LH/LL, BOS), // order blocks, fair value gaps, liquidité (equal highs/lows) et signaux ACHAT / VENTE avec alertes. //@version=5 indicator("Trading Evolution v2", shorttitle="Trading Evolution", overlay=true, max_boxes_count=200, max_lines_count=200, max_labels_count=300) // ───────────────────────── Paramètres ───────────────────────── grpT = "Tendance (trend cloud)" fastLen = input.int(12, "EMA rapide", minval=2, group=grpT) slowLen = input.int(34, "EMA lente", minval=3, group=grpT) filterLen = input.int(200, "EMA filtre de biais (0 = désactivé)", minval=0, group=grpT) showCloud = input.bool(true, "Afficher le nuage de tendance", group=grpT) grpS = "Structure de marché" swingLen = input.int(5, "Force des swings (bougies de chaque côté)", minval=2, maxval=20, group=grpS) showLabels= input.bool(true, "Étiquettes HH / HL / LH / LL", group=grpS) showBOS = input.bool(true, "Cassures de structure (BOS)", group=grpS) grpZ = "Zones" showOB = input.bool(true, "Order blocks", group=grpZ) showFVG = input.bool(true, "Fair value gaps", group=grpZ) showLiq = input.bool(true, "Liquidité (equal highs / lows)", group=grpZ) liqTol = input.float(0.1, "Tolérance liquidité (% du prix)", minval=0.01, step=0.01, group=grpZ) maxZones = input.int(6, "Zones affichées (max)", minval=1, maxval=30, group=grpZ) grpSig = "Signaux" showSig = input.bool(true, "Signaux ACHAT / VENTE", group=grpSig) useFilter = input.bool(true, "Filtrer par l'EMA de biais", group=grpSig) atrLen = input.int(14, "ATR (stop suggéré)", minval=1, group=grpSig) atrMult = input.float(1.5, "Multiplicateur ATR", minval=0.1, step=0.1, group=grpSig) rr = input.float(2.0, "Ratio risque / rendement", minval=0.5, step=0.5, group=grpSig) // Couleurs Trading Evolution (bleu & blanc) cBlue = color.new(#1657d6, 0) cBlueL = color.new(#2196f3, 0) cBlueF = color.new(#1657d6, 82) cNavy = color.new(#0a1628, 0) cNavyF = color.new(#0a1628, 90) cWhite = color.white cRed = color.new(#e0413f, 0) // ───────────────────────── Tendance ───────────────────────── emaF = ta.ema(close, fastLen) emaS = ta.ema(close, slowLen) emaB = filterLen > 0 ? ta.ema(close, filterLen) : na bull = emaF > emaS pF = plot(emaF, "EMA rapide", color=bull ? cBlue : cNavy, linewidth=2) pS = plot(emaS, "EMA lente", color=bull ? cBlueL : color.new(#6a7590, 0), linewidth=1) fill(pF, pS, color=showCloud ? (bull ? cBlueF : cNavyF) : na, title="Trend cloud") plot(emaB, "EMA de biais", color=color.new(#8fb4ff, 0), linewidth=1, style=plot.style_circles) // ───────────────────────── Structure ───────────────────────── ph = ta.pivothigh(high, swingLen, swingLen) pl = ta.pivotlow(low, swingLen, swingLen) var float lastH = na var float prevH = na var float lastL = na var float prevL = na var int lastHBar = na var int lastLBar = na if not na(ph) prevH := lastH lastH := ph lastHBar := bar_index - swingLen if showLabels label.new(bar_index - swingLen, ph, na(prevH) ? "H" : (ph > prevH ? "HH" : "LH"), style=label.style_label_down, color=cBlue, textcolor=cWhite, size=size.tiny) if not na(pl) prevL := lastL lastL := pl lastLBar := bar_index - swingLen if showLabels label.new(bar_index - swingLen, pl, na(prevL) ? "L" : (pl > prevL ? "HL" : "LL"), style=label.style_label_up, color=cBlueL, textcolor=cWhite, size=size.tiny) // Cassures de structure bosUp = showBOS and not na(lastH) and ta.crossover(close, lastH) bosDn = showBOS and not na(lastL) and ta.crossunder(close, lastL) if bosUp line.new(lastHBar, lastH, bar_index, lastH, color=cBlue, style=line.style_dashed) label.new(bar_index, lastH, "BOS", style=label.style_label_down, color=color.new(cBlue, 20), textcolor=cWhite, size=size.tiny) if bosDn line.new(lastLBar, lastL, bar_index, lastL, color=cNavy, style=line.style_dashed) label.new(bar_index, lastL, "BOS", style=label.style_label_up, color=color.new(cNavy, 20), textcolor=cWhite, size=size.tiny) // ───────────────────────── Order blocks ───────────────────────── var box[] obs = array.new_box() f_push(arr, b) => array.push(arr, b) if array.size(arr) > maxZones box.delete(array.shift(arr)) // OB haussier : dernière bougie baissière avant une impulsion qui casse un sommet if showOB and bosUp int k = 1 while k < 20 and not (close[k] < open[k]) k += 1 if k < 20 f_push(obs, box.new(bar_index - k, high[k], bar_index + 20, low[k], border_color=cBlue, bgcolor=color.new(#1657d6, 85), text="OB", text_color=cBlue, text_size=size.tiny, text_halign=text.align_left)) if showOB and bosDn int k2 = 1 while k2 < 20 and not (close[k2] > open[k2]) k2 += 1 if k2 < 20 f_push(obs, box.new(bar_index - k2, high[k2], bar_index + 20, low[k2], border_color=cNavy, bgcolor=color.new(#0a1628, 88), text="OB", text_color=cNavy, text_size=size.tiny, text_halign=text.align_left)) // ───────────────────────── Fair value gaps ───────────────────────── var box[] fvgs = array.new_box() fvgUp = showFVG and low > high[2] and (low - high[2]) > (high[2] - low[2]) * 0.5 fvgDn = showFVG and high < low[2] and (low[2] - high) > (high[2] - low[2]) * 0.5 if fvgUp f_push(fvgs, box.new(bar_index - 1, low, bar_index + 15, high[2], border_color=cBlueL, bgcolor=color.new(#2196f3, 84), text="FVG", text_color=cBlueL, text_size=size.tiny)) if fvgDn f_push(fvgs, box.new(bar_index - 1, low[2], bar_index + 15, high, border_color=cBlueL, bgcolor=color.new(#2196f3, 84), text="FVG", text_color=cBlueL, text_size=size.tiny)) // ───────────────────────── Liquidité ───────────────────────── tol = close * liqTol / 100 if showLiq and not na(ph) and not na(prevH) and math.abs(ph - prevH) <= tol line.new(bar_index - swingLen, math.max(ph, prevH), bar_index + 10, math.max(ph, prevH), color=cRed, style=line.style_dotted, width=2) label.new(bar_index + 10, math.max(ph, prevH), "$$$", style=label.style_label_left, color=cRed, textcolor=cWhite, size=size.tiny) if showLiq and not na(pl) and not na(prevL) and math.abs(pl - prevL) <= tol line.new(bar_index - swingLen, math.min(pl, prevL), bar_index + 10, math.min(pl, prevL), color=cRed, style=line.style_dotted, width=2) label.new(bar_index + 10, math.min(pl, prevL), "$$$", style=label.style_label_left, color=cRed, textcolor=cWhite, size=size.tiny) // ───────────────────────── Signaux ───────────────────────── atr = ta.atr(atrLen) biasOk(dir) => not useFilter or na(emaB) or (dir > 0 ? close > emaB : close < emaB) buySig = showSig and ta.crossover(emaF, emaS) and biasOk(1) sellSig = showSig and ta.crossunder(emaF, emaS) and biasOk(-1) plotshape(buySig, "ACHAT", style=shape.triangleup, location=location.belowbar, color=cBlue, size=size.small, text="ACHAT", textcolor=cBlue) plotshape(sellSig, "VENTE", style=shape.triangledown, location=location.abovebar, color=cNavy, size=size.small, text="VENTE", textcolor=cNavy) if buySig sl = close - atr * atrMult tp = close + (close - sl) * rr line.new(bar_index, sl, bar_index + 12, sl, color=cRed, style=line.style_dashed) line.new(bar_index, tp, bar_index + 12, tp, color=cBlue, style=line.style_dashed) if sellSig sl2 = close + atr * atrMult tp2 = close - (sl2 - close) * rr line.new(bar_index, sl2, bar_index + 12, sl2, color=cRed, style=line.style_dashed) line.new(bar_index, tp2, bar_index + 12, tp2, color=cBlue, style=line.style_dashed) // ───────────────────────── Alertes ───────────────────────── alertcondition(buySig, "Trading Evolution — ACHAT", "Signal ACHAT Trading Evolution sur {{ticker}} ({{interval}}) à {{close}}") alertcondition(sellSig, "Trading Evolution — VENTE", "Signal VENTE Trading Evolution sur {{ticker}} ({{interval}}) à {{close}}") alertcondition(bosUp or bosDn, "Trading Evolution — BOS", "Cassure de structure sur {{ticker}} ({{interval}})") // ───────────────────────── Tableau d'état ───────────────────────── var table t = table.new(position.top_right, 2, 3, bgcolor=color.new(cWhite, 0), border_color=color.new(#e3e9f5, 0), border_width=1) if barstate.islast table.cell(t, 0, 0, "Trading Evolution", text_color=cNavy, text_size=size.small) table.cell(t, 1, 0, bull ? "Haussier" : "Baissier", text_color=cWhite, bgcolor=bull ? cBlue : cNavy, text_size=size.small) table.cell(t, 0, 1, "Biais EMA " + str.tostring(filterLen), text_color=color.new(#6a7590, 0), text_size=size.tiny) table.cell(t, 1, 1, na(emaB) ? "—" : (close > emaB ? "Achats" : "Ventes"), text_color=cNavy, text_size=size.tiny) table.cell(t, 0, 2, "ATR", text_color=color.new(#6a7590, 0), text_size=size.tiny) table.cell(t, 1, 2, str.tostring(atr, format.mintick), text_color=cNavy, text_size=size.tiny)