PROTECTED SOURCE SCRIPT

EMA50 Flux H1

55
// 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 HTF — Version simple (flux direct)", overlay=true)

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

// === EMA50 classique sur la TF active ===
ema50 = ta.ema(close, lenEMA)

// === Flux H1 ===
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))

// === Volume HTF ===
vol_htf = request.security(syminfo.tickerid, htf, volume)
vol_ma_htf = request.security(syminfo.tickerid, htf, ta.sma(volume, obvLen))

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

// === Score total ===
score = obv_signal + imb_signal

// === Flux corrigé ===
flux = score > 0 ? 1 : score < 0 ? -1 : 0

// === Couleurs EMA ===
emaColor = flux > 0 ? color.lime : flux < 0 ? color.red : color.orange

// === Plot EMA50 colorée ===
plot(ema50, title="EMA50 Flux HTF", color=emaColor, linewidth=lineWidth)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.