
This is a trading strategy that combines the RSI indicator with the Parabolic SAR (PSAR) indicator, capturing market trends through dynamic overbought/oversold zones and PSAR crossover signals. The strategy incorporates a comprehensive risk management system, including take-profit and stop-loss mechanisms, along with position management for more robust trading performance.
The strategy is based on the following core logic: 1. Entry Signal: Long position triggered when price crosses above PSAR and RSI is in oversold territory (<30) 2. Exit Signal: Position closed when price crosses below PSAR and RSI is in overbought territory (>70) 3. Risk Control: 5% take-profit and 3% stop-loss for each trade, adjustable based on requirements 4. Signal Visualization: RSI indicator with dynamic color coding (green for oversold, red for overbought, blue for neutral) for intuitive market state display 5. Trade Alerts: Automatic notifications when buy/sell signals are triggered
The strategy establishes a complete trading system by combining PSAR and RSI indicators. Its strengths lie in clear signals and controlled risk, though market environment adaptability requires attention. Through continuous optimization and parameter adjustment, the strategy can achieve better trading results. It’s recommended to conduct thorough backtesting before live trading and adjust parameters according to specific market characteristics.
/*backtest
start: 2024-02-25 00:00:00
end: 2025-02-22 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("PSAR & RSI Strategy with Risk Management", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// User Inputs
psar_start = input.float(0.02, title="PSAR Start")
psar_increment = input.float(0.02, title="PSAR Increment")
psar_max = input.float(0.2, title="PSAR Max")
rsi_length = input.int(14, title="RSI Length")
rsi_overbought = input.int(70, title="RSI Overbought Level")
rsi_oversold = input.int(30, title="RSI Oversold Level")
tp_percent = input.float(5, title="Take Profit %") / 100 // Take Profit Level
sl_percent = input.float(3, title="Stop Loss %") / 100 // Stop Loss Level
// PSAR Calculation
psar = ta.sar(psar_start, psar_increment, psar_max)
// RSI Calculation
rsi = ta.rsi(close, rsi_length)
// Buy & Sell Conditions
buy_signal = ta.crossover(close, psar) and rsi < rsi_oversold
sell_signal = ta.crossunder(close, psar) and rsi > rsi_overbought
// Plot PSAR on Chart
plot(psar, style=plot.style_cross, color=color.blue, title="PSAR")
// Buy & Sell Signals on Chart
plotshape(series=buy_signal, location=location.belowbar, color=color.green, style=shape.labelup, title="BUY Signal")
plotshape(series=sell_signal, location=location.abovebar, color=color.red, style=shape.labeldown, title="SELL Signal")
// RSI Visualization (Dynamic Colors)
rsi_color = rsi > rsi_overbought ? color.red : rsi < rsi_oversold ? color.green : color.blue
plot(rsi, title="RSI", color=rsi_color, linewidth=2)
hline(rsi_overbought, "Overbought", color=color.red)
hline(rsi_oversold, "Oversold", color=color.green)
// Alerts for Buy & Sell
alertcondition(buy_signal, title="BUY Alert", message="Buy Signal Triggered!")
alertcondition(sell_signal, title="SELL Alert", message="Sell Signal Triggered!")
// Strategy Execution with Take Profit & Stop Loss
if buy_signal
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit / Stop Loss", from_entry="Buy", limit=close * (1 + tp_percent), stop=close * (1 - sl_percent))
if sell_signal
strategy.close("Buy")