確率強化に基づくRSI戦略


作成日: 2023-12-20 15:05:05 最終変更日: 2023-12-20 15:05:05
コピー: 0 クリック数: 666
1
フォロー
1621
フォロワー

確率強化に基づくRSI戦略

概要

この戦略は,RSI指標を用いて超買超売を判断する,単純に多額の戦略である.我々は,それを強化し,ストップ・ストップを追加し,確率モジュールを統合し,確率を高め,最近の一段間に利益のある取引の確率が51%以上である場合にのみポジションを開きます.これは,戦略のパフォーマンスを大幅に向上させます.

戦略原則

この戦略は,RSI指標を用いて市場の超買超売を判断する.具体的には,RSIが設定された超売区間の下限を破るときに多買する.また,RSIが設定された超売区間の上限を破るときに平仓する.さらに,我々はストップ・ストップ・割合を設定する.

重要なのは,確率判断モジュールを統合していることです.このモジュールは,最近の期間 (lookbackパラメータで設定) 内に,多取引が利益か損失の割合を統計します.近年の利益の取引の確率が51%以上である場合にのみ,多取引を開きます.これは,発生する可能性のある損失の取引を大幅に削減します.

優位分析

これは確率強化のRSI戦略で,通常のRSI戦略に比べて以下の利点があります.

  1. 単一損失を制限し,利益をロックする Stop Loss 設定を追加します.
  2. 確率モジュールを統合し,低利益率の市場を回避する vrf
  3. 確率モジュールのパラメータは調整可能で,異なる市場環境に対して最適化できます.
  4. シンプルで理解しやすく,実行しやすい

リスク分析

この戦略にはリスクもあります.

  1. 市場が低迷したからといって,余分に働けなくなっている.
  2. 確率モジュールの判断を間違えれば チャンスを逃してしまう
  3. 最適なパラメータの組み合わせを決定できず,異なる市場環境で大きな差異がある
  4. ストップ・ロスの設定が緩やかすぎると,単一の損失は大きくなる可能性があります.

対応方法:

  1. “空調”への参加を検討する
  2. 確率モジュールのパラメータを最適化し,誤判の可能性を低減する
  3. 機械学習による動的最適化パラメータ
  4. 単一損失のスペースを縮小するために,より保守的なストップレベルを設定します.

最適化の方向

この戦略は,以下の点でさらに最適化できます.

  1. バイ・ウェイ・トレードを実現する空白モジュール
  2. 機械学習による動的最適化パラメータ設定
  3. 他の指標で判断してみましょう
  4. ストップ・ストップ・ストップ戦略を最適化して,利益・損失比率を最適化
  5. フィルタリング信号と他の要素の組み合わせにより,確率を高めます.

要約する

この戦略は,単純なRSI戦略であり,統合確率判断モジュールを強化する.通常のRSI戦略と比較して,部分的な損益取引をフィルターして,全体的な撤回と損益比率が最適化される.その後,空白や動態最適化などの面で改善して,戦略をより堅牢にする.

ストラテジーソースコード
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-19 00:00:00
period: 1h
basePeriod: 15m
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/
// © thequantscience

//@version=5
strategy("Reinforced RSI",
     overlay = true,
     default_qty_type = strategy.percent_of_equity, 
     default_qty_value = 100,
     pyramiding = 1,
     currency = currency.EUR, 
     initial_capital = 1000,
     commission_type = strategy.commission.percent, 
     commission_value = 0.07)

lenght_rsi = input.int(defval = 14, minval = 1, title = "RSI lenght: ")
rsi = ta.rsi(close, length = lenght_rsi)

rsi_value_check_entry = input.int(defval = 35, minval = 1, title = "Oversold: ")
rsi_value_check_exit = input.int(defval = 75, minval = 1, title = "Overbought: ")

trigger = ta.crossunder(rsi, rsi_value_check_entry)
exit = ta.crossover(rsi, rsi_value_check_exit)

entry_condition   = trigger 
TPcondition_exit  = exit

look = input.int(defval = 30, minval = 0, maxval = 500, title = "Lookback period: ")

Probabilities(lookback) =>

    isActiveLong = false
    isActiveLong := nz(isActiveLong[1], false)
    isSellLong = false
    isSellLong := nz(isSellLong[1], false)

    int positive_results = 0
    int negative_results = 0

    float positive_percentage_probabilities = 0 
    float negative_percentage_probabilities = 0 

    LONG = not isActiveLong and entry_condition == true 
    CLOSE_LONG_TP = not isSellLong and TPcondition_exit == true

    p = ta.valuewhen(LONG, close, 0)
    p2 = ta.valuewhen(CLOSE_LONG_TP, close, 0)

    for i = 1 to lookback

	    if (LONG[i])
            isActiveLong := true
		    isSellLong := false

        if (CLOSE_LONG_TP[i])
	        isActiveLong := false
	        isSellLong := true

        if p[i] > p2[i]
            positive_results += 1
        else 
            negative_results -= 1 

	    positive_relative_probabilities = positive_results / lookback
	    negative_relative_probabilities = negative_results / lookback
	    positive_percentage_probabilities := positive_relative_probabilities * 100
	    negative_percentage_probabilities := negative_relative_probabilities * 100

    positive_percentage_probabilities
	
probabilities = Probabilities(look) 

lots = strategy.equity/close

var float e = 0 
var float c = 0 

tp = input.float(defval = 1.00, minval = 0, title = "Take profit: ")
sl = input.float(defval = 1.00, minval = 0, title = "Stop loss: ")

if trigger==true and strategy.opentrades==0 and probabilities >= 51
    e := close
    strategy.entry(id = "e", direction = strategy.long, qty = lots, limit = e) 
takeprofit = e + ((e * tp)/100)
stoploss = e - ((e * sl)/100)
if exit==true
    c := close 
    strategy.exit(id = "c", from_entry = "e", limit = c)
if takeprofit and stoploss 
    strategy.exit(id = "c", from_entry = "e", stop = stoploss, limit = takeprofit)