다중 시간대 동적 그리드 RSI 트렌드 쇼크 트레이딩 전략

RSI ATR MTF GRID DCA
생성 날짜: 2025-02-10 15:19:45 마지막으로 수정됨: 2025-02-10 15:19:45
복사: 0 클릭수: 591
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

다중 시간대 동적 그리드 RSI 트렌드 쇼크 트레이딩 전략

개요

이 전략은 다중 시간 주기의 RSI 지표와 동적 격자 거래 시스템을 결합한 복합 전략이다. 이 전략은 3개의 다른 시간 주기의 RSI 지표 값을 분석하여 시장의 과매매 상태를 식별하고, ATR 기반의 동적 격자 시스템을 사용하여 포지션 관리를 한다. 이 전략은 또한 매일 막대기, 최대 철회 보호와 같은 위험 제어 장치를 포함하며, 수익과 위험을 효과적으로 균형을 잡는다.

전략 원칙

전략의 핵심 논리는 다음과 같은 핵심 부분으로 구성됩니다.

  1. 다중 시간 주기 분석 - 현재 주기, 60분 및 240분 세 시간 주기의 RSI 지표를 동시에 모니터링하고, 세 주기가 오버 바이 또는 오버 셀 신호가 발생했을 때만 거래를 유발합니다.
  2. 동적 격자 시스템 - ATR을 변동률 참조로 사용하여 격자 간격을 동적으로 계산한다. 가격이 불리한 방향으로 이동할 때, 설정된 곱하기 인자에 따라 포지션을 증가시킨다.
  3. 포지션 관리 - 계정 이득의 1%를 기본 포지션으로 사용하고, lot_multiplier 파라미터를 통해 격자 추가 포지션의 폭을 제어한다.
  4. 위험 관리 - 일일 정지 목표, 2% 계정 이득의 최대 철회 보호, 반전 신호 평형 장치 등.

전략적 이점

  1. 다차원 신호 확인 - RSI 지표를 분석하여 여러 시간 주기를 사용하여 가짜 신호를 효과적으로 감소시킵니다.
  2. 유연한 포지션 관리 - 동적 격자 시스템은 시장의 변동에 따라 격자 간격을 조정할 수 있습니다.
  3. 잘 된 위험 제어 - 매일 정지 및 최대 철회 보호 장치가 효과적으로 위험을 제어한다.
  4. 고도 사용자 정의 - 다양한 시장 환경에 따라 최적화 전략을 수월하게 하기 위해 여러 가지 조정 가능한 매개 변수를 제공합니다.

전략적 위험

  1. 트렌드 위험 - 강한 트렌드 시장에서, 격자 전략은 지속적인 손실에 직면 할 수 있습니다. 트렌드 필터를 추가하는 것이 좋습니다.
  2. 재원 관리 위험 - 여러 개의 격자로는 재원이 과도하게 사용될 수 있습니다. 최대 격자 계층을 엄격히 통제하는 것이 좋습니다.
  3. 매개 변수 감수성 - 정책의 성능은 매개 변수 설정에 민감하다. 충분한 매개 변수 최적화 테스트를 수행하는 것이 좋습니다.

전략 최적화 방향

  1. 트렌드 인식 강화 - 이동 평균과 같은 트렌드 지표를 필터로 추가할 수 있다.
  2. 동적 변수 조정 - 시장의 변동에 따라 RSI 마이너스 및 격자 변수를 자동으로 조정합니다.
  3. 스톱로스 최적화 - 각 그리드 비트에 대해 개별 스톱로스를 설정할 수 있다.
  4. 시간 필터 - 거래 시간 필터를 추가하여 유동성이 낮은 시기를 피하십시오.

요약하다

이 전략은 다중 시간 주기의 RSI 분석과 동적 격자 거래 시스템을 결합하여 균형 잡힌 거래 프로그램을 만듭니다. 정교한 위험 제어 장치와 유연한 매개 변수 설정은 다양한 시장 환경에 적합합니다. 제안된 최적화 방향을 통해 전략의 안정성과 수익성을 더욱 향상시킬 수 있습니다.

전략 소스 코드
/*backtest
start: 2024-02-10 00:00:00
end: 2025-02-08 08:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Multi-Timeframe RSI Grid Strategy with Arrows", overlay=true)

// Input parameters
rsi_length = input.int(14, "RSI Length")
oversold = input.int(30, "Oversold Level")
overbought = input.int(70, "Overbought Level")
higher_tf1 = input.string("60", "Higher Timeframe 1")
higher_tf2 = input.string("240", "Higher Timeframe 2")
grid_factor = input.float(1.2, "Grid Multiplication Factor", step=0.1)
lot_multiplier = input.float(1.5, "Lot Multiplication Factor", step=0.1)
max_grid = input.int(5, "Maximum Grid Levels")
daily_target = input.float(4.0, "Daily Profit Target (%)", step=0.5)
atr_length = input.int(14, "ATR Length")

// Calculate RSI values
current_rsi = ta.rsi(close, rsi_length)
higher_tf1_rsi = request.security(syminfo.tickerid, higher_tf1, ta.rsi(close, rsi_length))
higher_tf2_rsi = request.security(syminfo.tickerid, higher_tf2, ta.rsi(close, rsi_length))

// Grid system variables
var int grid_level = 0
var float last_entry_price = na
var float base_size = strategy.equity * 0.01 / close
var float daily_profit_target = strategy.equity * (daily_target / 100)
var bool target_reached = false

// ATR for grid spacing
atr = ta.atr(atr_length)
grid_space = atr * grid_factor

// Daily reset
new_day = ta.change(time("D"))
if new_day
    daily_profit_target := strategy.equity * (daily_target / 100)
    target_reached := false
    grid_level := 0
    last_entry_price := na

// Trading conditions
buy_condition = current_rsi < oversold and higher_tf1_rsi < oversold and higher_tf2_rsi < oversold
sell_condition = current_rsi > overbought and higher_tf1_rsi > overbought and higher_tf2_rsi > overbought

// Reverse signal detection
reverse_long_to_short = sell_condition and strategy.position_size > 0
reverse_short_to_long = buy_condition and strategy.position_size < 0

// Close all trades on reverse signals
if reverse_long_to_short or reverse_short_to_long
    strategy.close_all()
    grid_level := 0
    last_entry_price := na

// Grid management logic
if strategy.position_size == 0
    grid_level := 0
    last_entry_price := na

if strategy.position_size > 0 and not reverse_long_to_short
    if close < last_entry_price - grid_space and grid_level < max_grid and not target_reached
        strategy.entry("Long Grid " + str.tostring(grid_level), strategy.long, qty=base_size * math.pow(lot_multiplier, grid_level))
        grid_level += 1
        last_entry_price := close

if strategy.position_size < 0 and not reverse_short_to_long
    if close > last_entry_price + grid_space and grid_level < max_grid and not target_reached
        strategy.entry("Short Grid " + str.tostring(grid_level), strategy.short, qty=base_size * math.pow(lot_multiplier, grid_level))
        grid_level += 1
        last_entry_price := close

// Initial entry
if buy_condition and strategy.position_size == 0 and not target_reached
    strategy.entry("Long", strategy.long, qty=base_size)
    grid_level := 1
    last_entry_price := close

if sell_condition and strategy.position_size == 0 and not target_reached
    strategy.entry("Short", strategy.short, qty=base_size)
    grid_level := 1
    last_entry_price := close

// Profit target check
current_profit = strategy.netprofit + strategy.openprofit
if current_profit >= daily_profit_target and not target_reached
    strategy.close_all()
    target_reached := true

// Drawdown protection
if strategy.openprofit < -(0.02 * strategy.equity)  // 2% drawdown protection
    strategy.close_all()
    grid_level := 0
    last_entry_price := na

// Plot Buy and Sell Arrows
plotshape(series=buy_condition and strategy.position_size == 0, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(series=sell_condition and strategy.position_size == 0, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)

// Plotting RSI
plot(current_rsi, "Current RSI", color=color.blue)
plot(higher_tf1_rsi, "HTF1 RSI", color=color.red)
plot(higher_tf2_rsi, "HTF2 RSI", color=color.green)
hline(oversold, "Oversold", color=color.gray)
hline(overbought, "Overbought", color=color.gray)