Chat gptLTIMINDTREE LTDNSE:LTIMvikramnikam60//@version=5 indicator("Smart Buy/Sell with SL & Target", overlay=true) // Parameters rsiPeriod = input.int(14, title="RSI Period") macdShort = input.int(12, title="MACD Short EMA") macdLong = input.int(26, title="MACD Long EMA") macdSignal = input.int(9, title="MACD Signal EMA") emaPeriod = input.int(20, title="EMA Period") riskReward = input.float(1.5, title="Risk:Reward", step=0.1) // Indicators rsi = ta.rsi(close, rsiPeriod) = ta.macd(close, macdShort, macdLong, macdSignal) ema = ta.ema(close, emaPeriod) // Conditions bullish = rsi < 35 and macdLine > signalLine and close > ema bearish = rsi > 65 and macdLine < signalLine and close < ema // Entry prices longEntry = bullish ? close : na shortEntry = bearish ? close : na // SL and TP (basic method: previous candle low/high) slLong = ta.valuewhen(bullish, low, 0) tpLong = bullish ? close + (close - slLong) * riskReward : na slShort = ta.valuewhen(bearish, high, 0) tpShort = bearish ? close - (slShort - close) * riskReward : na // Plot Buy/Sell plotshape(bullish, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(bearish, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL") // SL/TP Labels plot(bullish ? slLong : na, title="Stop Loss (Buy)", color=color.red, style=plot.style_linebr) plot(bullish ? tpLong : na, title="Target (Buy)", color=color.green, style=plot.style_linebr) plot(bearish ? slShort : na, title="Stop Loss (Sell)", color=color.red, style=plot.style_linebr) plot(bearish ? tpShort : na, title="Target (Sell)", color=color.green, style=plot.style_linebr)