//@version=5
indicator("LABEL MOMEMTUM", overlay=false)
// --- Paramètres Utilisateur ---
len = input.int(14, title="Période ADX/ATR")
th = input.int(25, title="Seuil de Force de Tendance (ADX)", minval=10, maxval=50)
th_low_adx = input.int(20, title="Seuil Bas ADX (pour Latéral)", minval=10,
maxval=40)
// Paramètres ATR en %
atr_length = input.int(14, title="Période ATR %")
atr_min_expansion_percent = input.float(0.05, title="Expansion Min. ATR % pour
Signal (ex: 0.05 pour 5%)", minval=0.01)
// Paramètres RSI
rsi_length = input.int(14, title="Période RSI")
rsi_ob = input.int(70, title="RSI Surachat")
rsi_os = input.int(30, title="RSI Survente")
// Paramètres MACD
fast_length_macd = input.int(12, title="MACD Fast Length")
slow_length_macd = input.int(26, title="MACD Slow Length")
signal_length_macd = input.int(9, title="MACD Signal Length")
// Paramètres Volume
vol_avg_length = input.int(200, title="Période Moyenne Mobile Volume")
volume_threshold_factor = input.float(1.5, title="Facteur de Seuil Volume (x MA
200)", minval=1.0, maxval=3.0, step=0.1)
// Bollinger Bands Parameters
bb_length = input.int(20, title="BB Période", minval=1)
bb_mult = input.float(2.0, title="BB Multiplicateur d'Écart Type", minval=0.1)
// Paramètres Stochastiques pour le Momentum
stoch_k_length = input.int(14, title="Stochastics %K Période", minval=1)
stoch_d_length = input.int(3, title="Stochastics %D Période", minval=1)
stoch_smoothing = input.int(3, title="Stochastics Lissage %K", minval=1)
stoch_overbought = input.int(80, title="Stochastics Surachat", minval=70,
maxval=90)
stoch_oversold = input.int(20, title="Stochastics Survente", minval=10, maxval=30)
// --- Calcul des indicateurs de base ---
TrueRange = ta.tr
DirectionalMovementPlus = high - high[1] > low[1] - low ? math.max(high - high[1],
0) : 0
DirectionalMovementMinus = low[1] - low > high - high[1] ? math.max(low[1] - low,
0) : 0
SmoothedTrueRange = ta.rma(TrueRange, len)
SmoothedDirectionalMovementPlus = ta.rma(DirectionalMovementPlus, len)
SmoothedDirectionalMovementMinus = ta.rma(DirectionalMovementMinus, len)
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = math.abs(DIPlus - DIMinus) / (DIPlus + DIMinus) * 100
ADX = ta.ema(DX, len)
adx_increasing = ADX > ADX[1]
adx_decreasing = ADX < ADX[1]
atr_value = ta.atr(atr_length)
atr_trend_up = close > close[1] and atr_value > atr_value[1] * (1 +
atr_min_expansion_percent)
atr_trend_down = close < close[1] and atr_value > atr_value[1] * (1 +
atr_min_expansion_percent)
rsi_value = ta.rsi(close, rsi_length)
rsi_overbought = rsi_value > rsi_ob
rsi_oversold = rsi_value < rsi_os
[macd_line, signal_line, hist_line] = ta.macd(close, fast_length_macd,
slow_length_macd, signal_length_macd)
avg_volume = ta.sma(volume, vol_avg_length)
volume_above_avg = volume > avg_volume * volume_threshold_factor
// Calcul du delta cumulatif de volume
var float cumulative_volume_delta = 0
volume_delta = volume - volume[1]
cumulative_volume_delta := cumulative_volume_delta + volume_delta
// Normalisation du delta cumulatif pour la jauge
max_cumulative_delta = ta.highest(math.abs(cumulative_volume_delta), 50)
normalized_delta = max_cumulative_delta != 0 ? cumulative_volume_delta /
max_cumulative_delta : 0
// Bollinger Bands and Bandwidth Calculation
bb_basis = ta.sma(close, bb_length)
bb_dev = bb_mult * ta.stdev(close, bb_length)
bb_upper = bb_basis + bb_dev
bb_lower = bb_basis - bb_dev
bb_bandwidth = (bb_upper - bb_lower) / bb_basis * 100
bb_expanding = bb_bandwidth > bb_bandwidth[1]
bb_contracting = bb_bandwidth < bb_bandwidth[1]
// Calcul Stochastique pour le Momentum
stoch_k = ta.sma(ta.stoch(close, high, low, stoch_k_length), stoch_smoothing)
stoch_d = ta.sma(stoch_k, stoch_d_length)
stoch_increasing = stoch_k > stoch_k[1]
stoch_decreasing = stoch_k < stoch_k[1]
stoch_cross_up = ta.crossover(stoch_k, stoch_d)
stoch_cross_down = ta.crossunder(stoch_k, stoch_d)
// --- Fonctions utilitaires ---
// Fonction: Couleur du Triangle ATR (Réactivité et Momentum de Volatilité)
getAtrTriangleColor(bool atr_trend_up_val, bool atr_trend_down_val) =>
if atr_trend_up_val
color.rgb(0, 150, 0) // Vert foncé pour forte volatilité haussière
else if atr_trend_down_val
color.rgb(150, 0, 0) // Rouge foncé pour forte volatilité baissière
else
color.gray // Grisé si volatilité stable ou indécise
// Fonction: Couleur du Triangle RSI (Momentum et Force)
getRsiTriangleColor(float rsi_val, float rsi_ob_val, float rsi_os_val, float
prev_rsi_val) =>
if rsi_val >= rsi_ob_val and rsi_val < prev_rsi_val // Surachat et
ralentissement (potentiel retournement)
color.rgb(255, 140, 0) // Orange (avertissement)
else if rsi_val <= rsi_os_val and rsi_val > prev_rsi_val // Survente et rebond
(potentiel retournement)
color.rgb(0, 191, 255) // Bleu ciel (potentiel rebond)
else if rsi_val > 50 and rsi_val > prev_rsi_val // Momentum haussier
color.green
else if rsi_val < 50 and rsi_val < prev_rsi_val // Momentum baissier
color.red
else
color.gray // Neutre / indécis
// Fonction: Couleur du Triangle MACD (Momentum de Tendance)
getMacdTriangleColor(float macd_line_val, float signal_line_val, float
prev_macd_line_val) =>
if macd_line_val > signal_line_val and macd_line_val > prev_macd_line_val //
Momentum haussier s'accélère
color.rgb(0, 128, 0) // Vert foncé
else if macd_line_val < signal_line_val and macd_line_val <
prev_macd_line_val // Momentum baissier s'accélère
color.rgb(128, 0, 0) // Rouge foncé
else if macd_line_val > signal_line_val // Momentum haussier mais peut-être
ralentit
color.green
else if macd_line_val < signal_line_val // Momentum baissier mais peut-être
ralentit
color.red
else
color.gray
getTriangleChar(color c) =>
if c == color.green or c == color.rgb(0, 150, 0) or c == color.rgb(0, 128, 0)
"▲"
else if c == color.red or c == color.rgb(150, 0, 0) or c == color.rgb(128, 0,
0)
"▼"
else
"●"
// Fonction: Obtenir la couleur et le texte de la jauge Bollinger avec information
de tendance
getBbGaugeInfo(float bandwidth, bool expanding, bool contracting, float
current_close, float bb_upper_val, float bb_lower_val, float bb_basis_val) =>
string bb_text_prefix = "BB: "
string trend_info = ""
color bb_text_color = color.white // Couleur par défaut
// Déterminer la tendance par rapport aux bandes et à la moyenne mobile
if current_close > bb_upper_val and bb_upper_val > bb_upper_val[1] // Prix au-
dessus de la bande supérieure et bande supérieure en hausse
trend_info := "📈 HAUSSE FORTE "
bb_text_color := color.rgb(0, 150, 0) // Vert foncé pour forte hausse
else if current_close < bb_lower_val and bb_lower_val < bb_lower_val[1] // Prix
en dessous de la bande inférieure et bande inférieure en baisse
trend_info := "📉 BAISSE FORTE "
bb_text_color := color.rgb(150, 0, 0) // Rouge foncé pour forte baisse
else if current_close > bb_basis_val and bb_basis_val > bb_basis_val[1] // Prix
au-dessus de la moyenne mobile et moyenne mobile en hausse
trend_info := "⬆️ HAUSSE "
bb_text_color := color.green // Vert
else if current_close < bb_basis_val and bb_basis_val < bb_basis_val[1] // Prix
en dessous de la moyenne mobile et moyenne mobile en baisse
trend_info := "⬇️ BAISSE "
bb_text_color := color.red // Rouge
else
trend_info := "↔️LATÉRALE "
bb_text_color := color.gray // Gris pour latérale
// Les seuils de volatilité et les caractères de la jauge restent pour la
couleur de la jauge
float low_volatility_threshold = 0.5
float medium_volatility_threshold = 1.5
string gauge_chars = ""
if expanding
if bandwidth >= medium_volatility_threshold
gauge_chars := "🟢████" // Vert vif
else if bandwidth >= low_volatility_threshold
gauge_chars := "🟡██" // Jaune
else
gauge_chars := "⚪█" // Blanc/Argenté
else if contracting
if bandwidth >= medium_volatility_threshold
gauge_chars := "🔴████" // Rouge vif
else if bandwidth >= low_volatility_threshold
gauge_chars := "🟠██" // Orange
else
gauge_chars := "⚫█" // Noir
else // Stable
if bandwidth >= medium_volatility_threshold
gauge_chars := "🔵████" // Bleu
else if bandwidth >= low_volatility_threshold
gauge_chars := "🟣██" // Violet
else
gauge_chars := "🟤█" // Marron
string bb_full_text = bb_text_prefix + trend_info + gauge_chars + " " +
str.tostring(bandwidth, "#.##") + "%"
[bb_full_text, bb_text_color]
// Fonction: Obtenir la couleur et le texte de la jauge ADX
getAdxGaugeInfo(float adx_value, float th_high, float th_low) =>
string adx_gauge_text = "ADX: " + str.tostring(adx_value, "#.##") + " "
color adx_gauge_color = color.gray
if adx_value >= th_high
adx_gauge_color := color.rgb(0, 128, 0)
adx_gauge_text += "██████"
else if adx_value >= th_low
adx_gauge_color := color.rgb(0, 80, 0)
adx_gauge_text += "███"
else
adx_gauge_color := color.gray
adx_gauge_text += "█"
[adx_gauge_text, adx_gauge_color]
// Fonction pour le label Momentum (Stochastique)
getMomentumInfo(float stoch_k_val, float stoch_d_val, bool stoch_increasing, bool
stoch_decreasing, bool stoch_cross_up_val, bool stoch_cross_down_val, float ob,
float os) =>
string momentum_text = "Momentum: "
color momentum_color = color.white
if stoch_cross_up_val and stoch_k_val < ob // Croisement haussier hors zone de
surachat = signal d'achat
momentum_text := "🚀 Achat Conf. (Stoch) "
momentum_color := color.rgb(0, 200, 0) // Vert vif
else if stoch_cross_down_val and stoch_k_val > os // Croisement baissier hors
zone de survente = signal de vente
momentum_text := " Vente Conf. (Stoch) "
momentum_color := color.rgb(200, 0, 0) // Rouge vif
else if stoch_k_val >= ob
momentum_text := "⚡ Surachat (Attention) "
momentum_color := color.rgb(255, 99, 71) // Tomato red
else if stoch_k_val <= os
momentum_text := "💧 Survente (Potentiel Rebond) "
momentum_color := color.rgb(65, 105, 225) // Royal blue
else if stoch_increasing
momentum_text := "📈 Hausse "
momentum_color := color.rgb(34, 139, 34) // Forest green
else if stoch_decreasing
momentum_text := "📉 Baisse "
momentum_color := color.rgb(178, 34, 34) // Firebrick red
else
momentum_text := "⚖️ Neutre "
momentum_color := color.gray
momentum_text += str.tostring(stoch_k_val, "#.##") + "%"
[momentum_text, momentum_color]
// Fonction: Obtenir la couleur et le texte de la jauge Volume basée sur le delta
cumulatif
getVolumeGaugeInfo(float current_volume, float avg_volume_val, float
cumulative_delta, float normalized_delta_val) =>
string volume_gauge_text = "Volume: "
color volume_gauge_color = color.gray
// Déterminer la couleur en fonction du delta cumulatif
if cumulative_delta > 0
volume_gauge_color := color.rgb(0, 150, 0) // Vert pour accumulation
volume_gauge_text += "🟢"
else if cumulative_delta < 0
volume_gauge_color := color.rgb(150, 0, 0) // Rouge pour distribution
volume_gauge_text += "🔴"
else
volume_gauge_color := color.gray // Gris pour neutre
volume_gauge_text += "⚪"
// Ajouter la jauge visuelle basée sur le volume normalisé
int gauge_length = math.round(math.abs(normalized_delta_val) * 6)
for i = 1 to gauge_length
volume_gauge_text += "|"
// Ajouter les valeurs numériques
volume_gauge_text += " " + str.tostring(current_volume, "#") + " (Δ:" +
str.tostring(cumulative_delta, "#") + ")"
[volume_gauge_text, volume_gauge_color]
// --- Labels et Alertes ---
var label atrLabel = label.new(na, na, "", style=label.style_label_left,
textcolor=color.white, size=size.normal)
var label rsiLabel = label.new(na, na, "", style=label.style_label_left,
textcolor=color.white, size=size.normal)
var label macdLabel = label.new(na, na, "", style=label.style_label_left,
textcolor=color.white, size=size.normal)
// Labels individuels pour ADX, BB, Volume et Momentum (avec fond transparent)
var label adxGaugeLabel = label.new(na, na, "", style=label.style_label_left,
textcolor=color.white, size=size.normal)
var label bbGaugeLabel = label.new(na, na, "", style=label.style_label_left,
textcolor=color.white, size=size.normal)
var label volumeLabel = label.new(na, na, "", style=label.style_label_left,
textcolor=color.white, size=size.normal)
var label momentumLabel = label.new(na, na, "", style=label.style_label_left,
textcolor=color.white, size=size.normal)
if barstate.islast
// Calcul des couleurs des triangles
color atr_tri_color = getAtrTriangleColor(atr_trend_up, atr_trend_down)
color rsi_tri_color = getRsiTriangleColor(rsi_value, rsi_ob, rsi_os,
rsi_value[1])
color macd_tri_color = getMacdTriangleColor(macd_line, signal_line,
macd_line[1])
// Obtenir les informations de jauge ADX et BB
[adx_gauge_text, adx_gauge_color] = getAdxGaugeInfo(ADX, th, th_low_adx)
[bb_gauge_text, bb_gauge_color] = getBbGaugeInfo(bb_bandwidth, bb_expanding,
bb_contracting, close, bb_upper, bb_lower, bb_basis)
// Obtenir les informations de momentum
[momentum_text, momentum_color] = getMomentumInfo(stoch_k, stoch_d,
stoch_increasing, stoch_decreasing, stoch_cross_up, stoch_cross_down,
stoch_overbought, stoch_oversold)
// Obtenir les informations de volume avec la nouvelle jauge
[volume_gauge_text, volume_gauge_color] = getVolumeGaugeInfo(volume,
avg_volume, cumulative_volume_delta, normalized_delta)
// Position et mise à jour des labels individuels
int x_offset = 1
int y_start = 10
int y_gap = 5
// Bollinger Bands gauge label
label.set_xy(bbGaugeLabel, bar_index + x_offset, y_start)
label.set_text(bbGaugeLabel, bb_gauge_text)
label.set_textcolor(bbGaugeLabel, bb_gauge_color)
label.set_color(bbGaugeLabel, color.rgb(0, 0, 0, 100))
label.set_xy(atrLabel, bar_index + x_offset, y_start + y_gap * 1)
label.set_text(atrLabel, "ATR: " + str.tostring(atr_value, "#.##") + " " +
getTriangleChar(atr_tri_color))
label.set_textcolor(atrLabel, atr_tri_color)
label.set_color(atrLabel, color.rgb(40, 40, 40, 90))
label.set_xy(rsiLabel, bar_index + x_offset, y_start + y_gap * 2)
label.set_text(rsiLabel, "RSI: " + str.tostring(rsi_value, "#.##") + " " +
getTriangleChar(rsi_tri_color))
label.set_textcolor(rsiLabel, rsi_tri_color)
label.set_color(rsiLabel, color.rgb(40, 40, 40, 90))
label.set_xy(macdLabel, bar_index + x_offset, y_start + y_gap * 3)
label.set_text(macdLabel, "MACD: " + str.tostring(macd_line, "#.##") + " " +
getTriangleChar(macd_tri_color))
label.set_textcolor(macdLabel, macd_tri_color)
label.set_color(macdLabel, color.rgb(40, 40, 40, 90))
// ADX gauge label
label.set_xy(adxGaugeLabel, bar_index + x_offset, y_start + y_gap * 4)
label.set_text(adxGaugeLabel, adx_gauge_text)
label.set_textcolor(adxGaugeLabel, adx_gauge_color)
label.set_color(adxGaugeLabel, color.rgb(0, 0, 0, 100))
// Volume gauge label (nouveau style)
label.set_xy(volumeLabel, bar_index + x_offset, y_start + y_gap * 5)
label.set_text(volumeLabel, volume_gauge_text)
label.set_textcolor(volumeLabel, volume_gauge_color)
label.set_color(volumeLabel, color.rgb(0, 0, 0, 100))
// Momentum Label
label.set_xy(momentumLabel, bar_index + x_offset, y_start + y_gap * 6)
label.set_text(momentumLabel, momentum_text)
label.set_textcolor(momentumLabel, momentum_color)
label.set_color(momentumLabel, color.rgb(0, 0, 0, 100))