//@version=5 strategy("RSI Strategy with 1% TP/SL", overlay=true)
// RSI settings rsiLength = 14 rsiOverbought = 70 rsiOversold = 30 rsi = ta.rsi(close, rsiLength)
// Entry conditions longCondition = ta.crossover(rsi, rsiOversold) shortCondition = ta.crossunder(rsi, rsiOverbought)
// Define stop-loss and take-profit levels longSL = strategy.position_avg_price * 0.99 // 1% stop-loss longTP = strategy.position_avg_price * 1.01 // 1% take-profit shortSL = strategy.position_avg_price * 1.01 // 1% stop-loss for short shortTP = strategy.position_avg_price * 0.99 // 1% take-profit for short
// Execute trades if (longCondition) strategy.entry("Long", strategy.long) strategy.exit("Long TP/SL", from_entry = "Long", limit = longTP, stop = longSL)
if (shortCondition) strategy.entry("Short", strategy.short) strategy.exit("Short TP/SL", from_entry = "Short", limit = shortTP, stop = shortSL)
// Plot RSI for reference plot(rsi, title="RSI", color=color.blue) hline(rsiOverbought, "Overbought", color=color.red) hline(rsiOversold, "Oversold", color=color.green)