この戦略は,RSI指標と移動平均を融合させ,トレンド判断と取引シグナルを生成し,移動ストップ・ロスト方式を使用して,利益をロックし,リスクを制御する.これは典型的なトレンド追跡取引戦略である.
戦略の原則:
RSI指標を計算し,超買い超売りを判断する. RSIが50以上なら多頭信号である.
高速移動平均を計算する. golden crossは多頭信号である.
RSIの上昇はトラッキングの信号として使えます.
入場後,移動停止線と停止線を設定する.
ストップラインは固定トラッキング価格の下,ストップフローは固定トラッキング価格上.
価格がストップ・ストップ・フリッジに触れたら平仓.
この戦略の利点は
RSIは,超買いと超売りを判断し,高と低を追いかけるのを避ける.
移動平均はトレンドの方向を識別する. 組み合わせは判断の正確性を高める.
モバイル・ストップ・ストップ・モードは,リアルタイム価格変化に応じてストップ・ポジションを調整できます.
この戦略のリスクは
RSI指数と平均線は,振動的な状況で誤信号を生じやすい.
モバイル・ストップ・ダメージ・ストップの幅は慎重に設定し,大きすぎても小さすぎても問題がある.
単一の損失の規模を制限できないので,大きな損失を招くリスクがある.
要するに,この戦略は,RSIと平均線指標の優位性を集約し,移動停止停止の方法でリスク管理を行う.パラメータの最適化とリスク管理の面で向上すれば,よりよい効果が得られます.
/*backtest
start: 2022-09-06 00:00:00
end: 2023-09-12 00:00:00
period: 4d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI and MA Strategy with Trailing Stop Loss and Take Profit",
overlay=true,
initial_capital=1000,
process_orders_on_close=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
commission_type=strategy.commission.percent,
commission_value=0.1)
showDate = input(defval=true, title='Show Date Range')
timePeriod = time >= timestamp(syminfo.timezone, 2022, 1, 1, 0, 0)
notInTrade = strategy.position_size <= 0
//==================================Buy Conditions============================================
//RSI
length = input(14)
rsi = ta.rsi(close, length)
buyCondition1 = rsi > 50
//MA
SMA9 = ta.sma(close, 9)
SMA50 = ta.sma(close, 50)
SMA100 = ta.sma(close, 100)
plot(SMA9, color = color.green)
plot(SMA50, color = color.orange)
plot(SMA100, color = color.blue)
buyCondition2 = SMA9 > SMA50//ta.crossover(SMA9, SMA100)
//RSI Increase
increase = 5
buyCondition3 = (rsi > rsi[1] + increase)
if (buyCondition1 and buyCondition2 and buyCondition3 and timePeriod) //and buyCondition
strategy.entry("Long", strategy.long)
//==================================Sell Conditions============================================
//Trailing Stop Loss and Take Profit
longTrailPerc = input.float(title='Trail Long Loss (%)', minval=0.0, step=0.1, defval=2) * 0.01
shortTrailPerc = input.float(title='Trail Short Loss (%)', minval=0.0, step=0.1, defval=1) * 0.01
longStopPrice = 0.0
shortStopPrice = 0.0
longStopPrice := if strategy.position_size > 0
stopValue = close * (1 - longTrailPerc)
math.max(stopValue, longStopPrice[1])
else
0
shortStopPrice := if strategy.position_size < 0
stopValue = close * (1 + shortTrailPerc)
math.min(stopValue, shortStopPrice[1])
else
999999
strategy.exit(id="Exit", stop = longStopPrice, limit = shortStopPrice)