
Il s’agit d’une stratégie de négociation automatisée basée sur les indicateurs techniques doubles RSI et MACD. Cette stratégie permet d’identifier les opportunités de négociation potentielles en combinant les signaux de survente et de survente avec la confirmation de la tendance.
La logique centrale de la stratégie repose sur les éléments clés suivants:
La stratégie a une bonne valeur pratique grâce à un contrôle raisonnable des risques et à l’optimisation des paramètres. Il est recommandé de faire un retour d’expérience suffisant avant l’application en direct et d’optimiser de manière ciblée en fonction des caractéristiques spécifiques du marché.
//@version=6
strategy("Debugging Demo GPT",
overlay=true,
initial_capital=100,
default_qty_type=strategy.percent_of_equity,
default_qty_value=3,
pyramiding=1,
calc_on_order_fills=true,
calc_on_every_tick=true,
slippage=3)
// -----------------------------------------------------------------------
// (1) Inputs: Start and End Date
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// (2) Indicators (RSI, MACD)
// -----------------------------------------------------------------------
// === RSI ===
rsiLen = input.int(14, "RSI Length")
rsiOB = input.int(80, "RSI Overbought")
rsiOS = input.int(20, "RSI Oversold")
rsiVal = ta.rsi(close, rsiLen)
// === MACD ===
fastLen = input.int(12, "MACD Fast Length")
slowLen = input.int(26, "MACD Slow Length")
sigLen = input.int(9, "MACD Signal Length")
[macdLine, sigLine, histLine] = ta.macd(close, fastLen, slowLen, sigLen)
// -----------------------------------------------------------------------
// (3) Trading Logic: LONG/SHORT Filters
// -----------------------------------------------------------------------
bool rsiLongOk = (rsiVal < rsiOB)
bool rsiShortOk = (rsiVal > rsiOS)
bool macdLongOk = (macdLine > sigLine)
bool macdShortOk = (macdLine < sigLine)
bool longCondition = rsiLongOk and macdLongOk
bool shortCondition = rsiShortOk and macdShortOk
// -----------------------------------------------------------------------
// (4) Entry Conditions
// -----------------------------------------------------------------------
// Debugging: Visualizing the conditions
plotshape(series=longCondition, location=location.belowbar, color=color.blue, style=shape.circle, title="LongCondition", size=size.tiny)
plotshape(series=shortCondition, location=location.abovebar, color=color.orange, style=shape.circle, title="ShortCondition", size=size.tiny)
// Entries only when all conditions are met
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
// -----------------------------------------------------------------------
// (5) Plotting for Visualization
// -----------------------------------------------------------------------
// RSI Plots
hline(rsiOB, "RSI Overbought", color=color.red, linestyle=hline.style_dotted)
hline(rsiOS, "RSI Oversold", color=color.green, linestyle=hline.style_dotted)
plot(rsiVal, title="RSI", color=color.purple)
// MACD Plots
plot(macdLine, color=color.teal, title="MACD Line")
plot(sigLine, color=color.orange, title="MACD Signal")
plot(histLine, style=plot.style_histogram, color=(histLine >= 0 ? color.lime : color.red), title="MACD Histogram")