OPEN-SOURCE SCRIPT

EMA50 Flux LT (Daily/Weekly)

90
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © pizzalolodudu

//version=6
indicator("EMA50 Flux LT (Daily/Weekly)", overlay=true)

// === Inputs ===
lenEMA = input.int(50, "Longueur EMA prix")
obvLen = input.int(20, "OBV MA length")
htf = input.timeframe("W", "Timeframe Flux (HTF)") // Par défaut : Weekly
lineWidth = input.int(6, "Épaisseur EMA", minval=1, maxval=12)

// === EMA50 sur la TF active (ex: Daily chart) ===
ema50 = ta.ema(close, lenEMA)

// === Flux HTF (Weekly ou Monthly) ===
obv_htf = request.security(syminfo.tickerid, htf, ta.cum(math.sign(ta.change(close)) * volume))
obv_ma_htf = request.security(syminfo.tickerid, htf, ta.sma(ta.cum(math.sign(ta.change(close)) * volume), obvLen))

imb_htf = request.security(syminfo.tickerid, htf, (close > open ? 1 : -1))

// === Signaux binaires ===
obv_signal = obv_htf > obv_ma_htf ? 1 : -1
imb_signal = imb_htf > 0 ? 1 : -1

// === Score total revisité ===
score = obv_signal + imb_signal
flux = score > 0 ? 1 : score < 0 ? -1 : 0

// === Couleurs ===
colFlux = flux > 0 ? color.lime : flux < 0 ? color.red : color.orange
colOutline = color.new(color.white, 70)

// === Tracé double couche ===
plot(ema50, color=colOutline, linewidth=lineWidth + 2, title="Contour EMA")
plot(ema50, color=colFlux, linewidth=lineWidth, title="EMA Flux LT")

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.