//@version=5
indicator("Cumpără la scădere (orice monedă)", overlay=true)
// === INPUTURI ===
stochKLen = input.int(14, "Lungimea Stochastic %K")
stochDLen = input.int(3, "Lungimea Stochastic %D")
stochSmooth = input.int(3, "Netezire Stochastic")
buyZone = input.float(0.98, "Zona de cumpărare % (de exemplu 0.98 = 2% sub)", step=0.01)
tpMultiplier = input.float(1.05, "Procentaj Profit Luat (de exemplu 1.05 = 5% peste)", step=0.01)
slMultiplier = input.float(0.97, "Procentaj Stop Loss (de exemplu 0.97 = 3% sub)", step=0.01)
// === OSCILATORUL STOCHASTIC ===
k = ta.sma(ta.stoch(close, high, low, stochKLen), stochSmooth)
d = ta.sma(k, stochDLen)
// === NIVELURI DINAMICE ===
var float entryPrice = na
var bool inTrade = false
// === CONDIȚII DE CUMĂRĂTURĂ ===
buyCondition = ta.crossover(k, d) and k < 80
if (buyCondition and not inTrade)
entryPrice := close
inTrade := true
// === NIVELURI TP și SL ===
takeProfitPrice = entryPrice * tpMultiplier
stopLossPrice = entryPrice * slMultiplier
// === CONDIȚII DE IESIRE ===
exitConditionTP = inTrade and close >= takeProfitPrice
exitConditionSL = inTrade and close <= stopLossPrice
if (exitConditionTP or exitConditionSL)
inTrade := false
entryPrice := na
// === REPREZENTĂRI GRAFICE ===
plotshape(buyCondition and not inTrade, title="Semnal de cumpărare", location=location.belowbar, color=color.green, style=shape.labelup, text="CUMĂRĂ")
plotshape(exitConditionTP, title="Profit Luat", 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="Prețul de intrare", color=color.new(color.green, 60))
plot(inTrade ? takeProfitPrice : na, title="Nivelul Profitului Luat", color=color.new(color.red, 60), style=plot.style_line)
plot(inTrade ? stopLossPrice : na, title="Nivelul Stop Loss", color=color.new(color.orange, 60), style=plot.style_line)
#pinescript #Write2Earn