//@version=5
indicator("Achetez la Stratégie de Baisse (Toute Monnaie)", overlay=true)
// === ENTRÉES ===
stochKLen = input.int(14, "Longueur Stochastique %K")
stochDLen = input.int(3, "Longueur Stochastique %D")
stochSmooth = input.int(3, "Lissage Stochastique")
buyZone = input.float(0.98, "Zone d'Achat % (ex. 0.98 = 2% en dessous)", step=0.01)
tpMultiplier = input.float(1.05, "Prendre Profit % (ex. 1.05 = 5% au-dessus)", step=0.01)
slMultiplier = input.float(0.97, "Stop Loss % (ex. 0.97 = 3% en dessous)", step=0.01)
// === OSCILLATEUR STOCHASTIQUE ===
k = ta.sma(ta.stoch(close, high, low, stochKLen), stochSmooth)
d = ta.sma(k, stochDLen)
// === NIVEAUX DYNAMIQUES ===
var float entryPrice = na
var bool inTrade = false
// === CONDITIONS D'ACHAT ===
buyCondition = ta.crossover(k, d) and k < 80
if (buyCondition and not inTrade)
entryPrice := close
inTrade := true
// === NIVEAUX TP et SL ===
takeProfitPrice = entryPrice * tpMultiplier
stopLossPrice = entryPrice * slMultiplier
// === CONDITIONS DE SORTIE ===
exitConditionTP = inTrade and close >= takeProfitPrice
exitConditionSL = inTrade and close <= stopLossPrice
if (exitConditionTP or exitConditionSL)
inTrade := false
entryPrice := na
// === TRACÉS ===
plotshape(buyCondition and not inTrade, title="Signal d'Achat", location=location.belowbar, color=color.green, style=shape.labelup, text="ACHETER")
plotshape(exitConditionTP, title="Prendre Profit", location=location.abovebar, color=color.red, style=shape.labeldown, text="TP")
plotshape(exitConditionSL, title="Stop Loss", location=location.abovebar, color=color.orange, style=shape.labeldown, text="SL")
plot(entryPrice, title="Prix d'Entrée", color=color.new(color.green, 60))
plot(inTrade ? takeProfitPrice : na, title="Niveau de Prise de Profit", color=color.new(color.red, 60), style=plot.style_line)
plot(inTrade ? stopLossPrice : na, title="Niveau de Stop Loss", color=color.new(color.orange, 60), style=plot.style_line)
#pinescript #Write2Earn