확률 향상을 기반으로 한 RSI 전략


생성 날짜: 2023-12-20 15:05:05 마지막으로 수정됨: 2023-12-20 15:05:05
복사: 0 클릭수: 668
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

확률 향상을 기반으로 한 RSI 전략

개요

이 전략은 단순한 그냥 더 많이 하고, RSI 지표를 사용하여 과매매를 판단하는 전략이다. 우리는 이것을 강화하고, 중지 손실을 추가하고, 확률 모듈을 통합하여 확률을 높이고, 최근 기간 동안 수익 거래의 확률이 51%보다 크거나 같을 때만 포지션을 개설한다. 이것은 전략의 성능을 크게 향상시킨다.

전략 원칙

이 전략은 RSI 지표를 사용하여 시장의 과매매를 판단합니다. 구체적으로, RSI가 설정된 과매 영역의 하위 한계를 넘어서면 더 많이합니다. RSI가 설정된 과매 영역의 상위 한계를 넘어서면 평소합니다. 또한, 우리는 스톱 스톱 비율을 설정합니다.

중요한 것은, 우리는 확률 판단 모듈을 통합했다. 이 모듈은 최근 기간 동안 (lookback 파라미터를 통해 설정된) 더 많은 거래를 한 것이 손실인지의 비율을 통계화한다. 최근 수익 거래의 확률이 51% 이상일 때만 더 많은 위치를 열 수 있다. 이것은 손실 거래의 가능성을 크게 줄여준다.

우위 분석

이 RSI 전략은 확률을 높여서 일반 RSI 전략에 비해 다음과 같은 장점을 가지고 있습니다.

  1. 단편 손실을 제한하고 수익을 고정하는 스톱 로스 설정을 추가합니다.
  2. 확률 모듈을 통합하여 수익률이 낮은 vrf 시장을 피합니다.
  3. 확률 모듈의 매개 변수는 조정 가능하며 다양한 시장 환경에 최적화 할 수 있습니다.
  4. 단순히 여러 가지 메커니즘을 간단하게 이해하고 실행하기 쉽다.

위험 분석

이 전략에는 위험도 있습니다.

  1. 하지만, 이 시장이 무너지면서도 수익을 낼 수 없는 것은 과잉 노동일 뿐입니다.
  2. 확률 모듈의 잘못된 판단으로 더 좋은 기회를 놓칠 수 있습니다.
  3. 최적의 변수 조합을 결정할 수 없으며, 시장 환경에 따라 성능이 크게 달라집니다.
  4. 단독 손실이 너무 커질 수 있기 때문에 손해배상 설정이 너무 완만하다.

대응방법:

  1. 카카오페이지에 가입할 수 있습니다.
  2. 확률 모듈 변수를 최적화하여 잘못된 판단의 확률을 감소시킵니다.
  3. 기계 학습 방법을 사용하는 동적 최적화 매개 변수
  4. 단편 손실을 줄이기 위해 더 보수적인 스톱 레벨을 설정합니다.

최적화 방향

이 전략은 다음의 몇 가지 측면에서 더 개선될 수 있습니다.

  1. 2방향 거래에 대한 포커스 모듈을 추가
  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)