RSI 平均逆転取引戦略

作者: リン・ハーンチャオチャン, 日付: 2023-09-12 14:37:28
タグ:

この戦略は,RSI指標の平均逆転特性に基づいています.過買い過売のRSIは,取引機会を生み出し,逆転傾向にあります.この戦略は,RSIを使用して長期/短期ポジションを体系的に確立するために過買い/過売状態を特定します.

戦略論理:

  1. RSI値を計算し,通常 60 と 30 の過剰購入と過剰販売の値を設定します.

  2. RSIが過買い線を横切ると ショートします

  3. RSIが過剰売り上げ線を越えると 売り切れる

  4. ロングストップ損失はエントリー価格 * (1 - ストップ損失 %).ショートストップ損失はエントリー価格 * (1 + ストップ損失 %).

  5. ストップ・ロスを切ると,ポジションを終了します.

利点:

  1. RSI を使ってトレンドの引き下げ時に逆転の機会を把握する.

  2. ブレイクアウト取引はトレンドの逆転時に 適時に入場できる

  3. ストップ・ロスは,単一の取引の損失額を制御する.

リスク:

  1. RSIは誤ったシグナルを与える傾向があります.他の指標で確認してください.

  2. ストップ損失が狭すぎると 過剰なストップが起こります 範囲を広げることを考慮してください

  3. 入札のタイミングが悪い場合,ポジションが大きすぎる可能性があります.

概要すると,RSIの平均逆転戦略は,RSIの過剰拡張を取引する.単一の取引で制御された損失を伴う傾向に従っている.しかし,RSIの信頼性は低い.投資家は他の確認指標,最適化されたストップと慎重に使用し,控えめな長期的リターンを期待すべきである.


/*backtest
start: 2022-09-05 00:00:00
end: 2023-09-11 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © relevantLeader16058

//@version=4
strategy(shorttitle='RSI Bot Strategy',title='Quadency Mean Reversion Bot Strategy', overlay=true, initial_capital = 100, process_orders_on_close=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type=strategy.commission.percent, commission_value=0.08)

//Backtest dates
start = input(defval = timestamp("08 Mar 2021 00:00 -0600"), title = "Start Time", type = input.time)
finish = input(defval = timestamp("9 Mar 2021 23:59 -0600"), title = "Start Time", type = input.time)
window()  => true       // create function "within window of time"

// Complete Control over RSI inputs and source price calculations
lengthRSI = input(14, minval=1)
source = input(title="Source", type=input.source, defval=close)
strat = input(title="Strategy", defval="Long/Short", options=["Long Only", "Long/Short", "Short Only"])
strat_val = strat == "Long Only" ? 1 : strat == "Long/Short" ? 0 : -1
stoploss = input(5.00, "Stop Loss %")
oversold= input(30)
overbought= input(60)

// Standard RSI Calculation
RSI = rsi(close, lengthRSI)
stLossLong=(1-(stoploss*.01))
stLossShort=(1+(stoploss*.01))

//Long and Short Strategy Logic
GoLong = crossunder(RSI, oversold) and window()
GoShort = crossover(RSI, overbought) and window()

// Strategy Entry and Exit
if (GoLong)
    if strat_val > -1
        strategy.entry("LONG", strategy.long)
    if strat_val < 1
        strategy.close("SHORT")
    

if (GoShort)
    if strat_val > -1
        strategy.close("LONG")
    if strat_val < 1
        strategy.entry("SHORT", strategy.short)


LongStopLoss = barssince(GoLong)<barssince(GoShort) and crossunder(low, valuewhen(GoLong, close, 0)*stLossLong)

ShortStopLoss = barssince(GoLong)>barssince(GoShort) and crossover(high, valuewhen(GoShort, close, 0)*stLossShort)

if (ShortStopLoss)
    strategy.close("SHORT")
    
if (LongStopLoss)
    strategy.close("LONG")






もっと