確率強化RSI戦略

作者: リン・ハーンチャオチャン開催日:2023年12月20日15時05分05秒
タグ:

img

概要

これは,過剰購入および過剰販売レベルを決定するためにRSI指標を使用する簡単な長期のみ戦略です.ストップ損失と利益を引き取りを追加し,最近の収益性の高い取引の確率が51%以上の場合のみ強化取引に確率モジュールを統合することで,過剰購入および過剰売却レベルを決定しました.これは潜在的な損失取引を回避することによって戦略のパフォーマンスを大幅に改善しました.

原則

この戦略は,市場過剰購入および過剰販売状態を判断するために,RSI指標を使用します.特に,RSIが過剰販売ゾーンの下限を下回ると,RSIが過剰購入ゾーンの上限を下回るとポジションを閉じる.さらに,ストップ損失と利益率を設定します.

鍵は,確率判断モジュールを統合したことです. このモジュールは,最近の期間のロングトレード (lookbackパラメータによって定義される) の収益率を計算します. 最近の収益性の高いトレードの可能性が 51% 以上またはそれと同等である場合にのみエントリを許可します. これにより,多くの潜在的な損失トレードを回避します.

利点

確率強化RSI戦略として,単純なRSI戦略と比較して以下の利点があります.

  1. 追加ストップ損失と利益取得 単一の取引損失を制御し,利益をロック
  2. 統合された確率モジュールは低確率市場を回避する
  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)

もっと