
この戦略は,相対的に強い指数 ((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")