
이 전략은 상대적으로 약한 지수 ((RSI) 기술 지표를 기반으로 자산의 과매매와 과매매 상태를 분석하여 거래 결정을 내립니다. RSI가 과매매 경계를 초과할 때 구매 신호를 유발하고 RSI가 과매매 경계를 초과할 때 판매 신호를 유발합니다.
RSI에 기반한 퍼센티지 스톱 스톱 손실 거래 전략은 시장의 과매매 과매매 상태를 포착하여 고정된 퍼센티지 스톱 스톱 손실 메커니즘과 결합하여 트렌드 반전 시 적시에 평형하여 안정적인 수익을 얻습니다. 이 전략의 원리는 간단하고 이해하기 쉽습니다. 위험 제어 가능하며 적응력이 강합니다.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI Strategy with Adjustable TP and SL", overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=10,
initial_capital=100000,
currency=currency.USD,
commission_type=strategy.commission.percent,
commission_value=0.1)
// RSI settings
rsiPeriod = input.int(14, title="RSI Period")
rsiOverbought = input.int(70, title="RSI Overbought Level", minval=50, maxval=100)
rsiOversold = input.int(30, title="RSI Oversold Level", minval=0, maxval=50)
// Fixed TP and SL settings
takeProfitPct = input.float(20, title="Take Profit Percentage", step=0.1) / 100
stopLossPct = input.float(5, title="Stop Loss Percentage", step=0.1) / 100
// Calculate RSI
rsiValue = ta.rsi(close, rsiPeriod)
// Plot RSI
hline(rsiOverbought, "RSI Overbought", color=color.red)
hline(rsiOversold, "RSI Oversold", color=color.green)
plot(rsiValue, title="RSI", color=color.purple)
// Entry conditions
buyCondition = ta.crossunder(rsiValue, rsiOversold)
sellCondition = ta.crossover(rsiValue, rsiOverbought)
// Calculate stop loss and take profit prices
var float entryPrice = na
var float stopLossLevel = na
var float takeProfitLevel = na
if (buyCondition)
entryPrice := close
stopLossLevel := entryPrice * (1 - stopLossPct)
takeProfitLevel := entryPrice * (1 + takeProfitPct)
strategy.entry("Buy", strategy.long)
// Close positions when TP or SL is hit
if (strategy.position_size > 0)
if (close <= stopLossLevel)
strategy.close("Buy", comment="Stop Loss Hit")
if (close >= takeProfitLevel)
strategy.close("Buy", comment="Take Profit Hit")
// Close positions when RSI crosses above overbought level
if (sellCondition)
strategy.close("Buy", comment="RSI Overbought")
// Optional: Add alerts
alertcondition(buyCondition, title="Buy Alert", message="RSI crossed below oversold level")
alertcondition(sellCondition, title="Sell Alert", message="RSI crossed above overbought level")