OPEN-SOURCE SCRIPT

Patrice - GC M1 Bot (MACD EMA RSI)

38
//version=6
indicator("Patrice - GC M1 Bot (MACD EMA RSI)", overlay = true)

//----------------------
// Inputs (optimisés GC)
//----------------------
emaLenFast = input.int(9, "EMA rapide")
emaLenSlow = input.int(14, "EMA lente")
rsiLen = input.int(14, "RSI length")
atrLen = input.int(14, "ATR length")
volLen = input.int(20, "Volume moyenne")

slMult = input.float(0.4, "SL = ATR x", step = 0.1)
tpMult = input.float(0.7, "TP = ATR x", step = 0.1)
minAtr = input.float(0.7, "ATR minimum pour trader", step = 0.1)

maxDistEmaPct = input.float(0.3, "Distance max EMA9 (%)", step = 0.1)

//----------------------
// Indicateurs
//----------------------
ema9 = ta.ema(close, emaLenFast)
ema14 = ta.ema(close, emaLenSlow)

[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
hist = macdLine - signalLine

rsi = ta.rsi(close, rsiLen)
atr = ta.atr(atrLen)

volMa = ta.sma(volume, volLen)

//----------------------
// Session 9:30 - 11:00 (NY)
//----------------------
hourSession = hour(time, "America/New_York")
minuteSession = minute(time, "America/New_York")

inSession = (hourSession == 9 and minuteSession >= 30) or
(hourSession > 9 and hourSession < 11) or
(hourSession == 11 and minuteSession == 0)

//----------------------
// Filtres vol / ATR / distance EMA
//----------------------
volFilter = volume > volMa
atrFilter = atr > minAtr
distEmaPct = math.abs(close - ema9) / close * 100.0
distFilter = distEmaPct < maxDistEmaPct

//----------------------
// Tendance
//----------------------
bullTrend = close > ema9 and close > ema14 and ema9 > ema14
bearTrend = close < ema9 and close < ema14 and ema9 < ema14

//----------------------
// MACD : 2e barre
//----------------------
bullSecondBar = hist > 0 and hist[1] > 0 and hist[2] <= 0
bearSecondBar = hist < 0 and hist[1] < 0 and hist[2] >= 0

//----------------------
// Filtres RSI
//----------------------
rsiLongOk = rsi < 70 and rsi >= 45 and rsi <= 65
rsiShortOk = rsi > 30 and rsi >= 35 and rsi <= 55

//----------------------
// Gestion du risque (simple pour l'instant)
//----------------------
canTradeRisk = true

//----------------------
// Conditions d'entrée
//----------------------
longCond = bullTrend and bullSecondBar and rsiLongOk and inSession and volFilter and atrFilter and distFilter and canTradeRisk
shortCond = bearTrend and bearSecondBar and rsiShortOk and inSession and volFilter and atrFilter and distFilter and canTradeRisk

//----------------------
// SL / TP (info seulement, pas d'ordres)
//----------------------
slPoints = atr * slMult
tpPoints = atr * tpMult

longSL = close - slPoints
longTP = close + tpPoints
shortSL = close + slPoints
shortTP = close - tpPoints

//----------------------
// Visuels
//----------------------
plot(ema9, title = "EMA 9")
plot(ema14, title = "EMA 14")

plotshape(longCond, title = "Signal Long", style = shape.triangleup, location = location.belowbar, size = size.tiny, text = "L")
plotshape(shortCond, title = "Signal Short", style = shape.triangledown, location = location.abovebar, size = size.tiny, text = "S")

//----------------------
// Conditions d'ALERTE
//----------------------
alertcondition(longCond, title = "ALERTE LONG", message = "Signal LONG Patrice GC bot")
alertcondition(shortCond, title = "ALERTE SHORT", message = "Signal SHORT Patrice GC bot")

Exención de responsabilidad

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.