RSI 동적 위치 평균화 전략

저자:차오장, 날짜: 2024-02-06 09:44:05
태그:

img

전반적인 설명

이 전략은 상대적 강도 지수 (RSI) 와 마틴게일 포지션 평균화 원칙을 결합한다. RSI가 과판 라인 이하로 떨어지면 긴 포지션을 시작하고 가격이 계속 하락하면 포지션을 두 배로 낮춰준다. 이윤 취득은 작은 목표와 함께 달성된다. 이 전략은 안정적인 이익을 위해 스팟 거래에서 높은 시가총액 동전에 적합하다.

전략 논리

  1. RSI 지표를 사용하여 시장 과잉 판매 상황을 식별합니다. RSI 기간은 14로 설정하고 과잉 판매 문턱은 30으로 설정합니다.
  2. RSI가 < 30이 되면 계정 자금의 5%로 첫 번째 긴 포지션을 시작합니다.
  3. 만약 가격이 초기 진입 가격에서 0.5% 감소한다면, 포지션 크기를 두 배로 하락으로 평균화합니다. 만약 가격이 더 하락한다면, 포지션 크기를 네 배로 하락으로 평균화합니다.
  4. 매번 0.5%의 수익을 얻습니다.
  5. 반복하세요.

이점 분석

  • 좋은 출입 지점의 RSI를 사용하여 시장 과판 상황을 식별합니다.
  • 마틴게일 포지션 평균은 평균 진입 가격을 낮춰줍니다.
  • 작은 수익을 얻는 것은 일관성 있는 이득을 가능하게 합니다.
  • 고시장 가치의 동전에서 통제된 위험을 위한 스팟 거래에 적합합니다.

위험 분석

  • 장기적인 시장 침체는 큰 손실로 이어질 수 있습니다.
  • 손해를 막지 않는 것은 무한한 부진을 의미합니다.
  • 너무 많은 평균이 손실을 증가시킵니다.
  • 아직은 내재된 장기 방향 위험도 있습니다.

최적화 방향

  1. 최대 손실을 제한하기 위해 스톱 손실을 포함합니다.
  2. RSI 매개 변수를 최적화하여 가장 좋은 과잉 구매/ 과잉 판매 신호를 찾습니다.
  3. 특정 동전의 변동성에 따라 합리적인 수익 범위가 설정됩니다.
  4. 전체 자산 또는 포지션 사이즈링 규칙에 기초한 평균 속도

요약

이 전략은 RSI 지표와 마틴게일 포지션 평균을 결합하여 적절한 평균화로 과판 상황을 활용하고 안정적인 이익을 위해 작은 수익을 취합니다. 중지 손실, 매개 변수 조정 등을 통해 줄일 수있는 위험이 있습니다.


/*backtest
start: 2024-01-06 00:00:00
end: 2024-02-05 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Stavolt

//@version=5
strategy("RSI Martingale Strategy", overlay=true, default_qty_type=strategy.cash, currency=currency.USD)

// Inputs
rsiLength = input(14, title="RSI Length")
oversoldThreshold = input(30, title="Oversold Threshold") // Keeping RSI threshold
profitTargetPercent = input(0.5, title="Profit Target (%)") / 100
initialInvestmentPercent = input(5, title="Initial Investment % of Equity")

// Calculating RSI
rsiValue = ta.rsi(close, rsiLength)

// State variables for tracking the initial entry
var float initialEntryPrice = na
var int multiplier = 1

// Entry condition based on RSI
if (rsiValue < oversoldThreshold and na(initialEntryPrice))
    initialEntryPrice := close
    strategy.entry("Initial Buy", strategy.long, qty=(strategy.equity * initialInvestmentPercent / 100) / close)
    multiplier := 1

// Adjusting for errors and simplifying the Martingale logic
// Note: This section simplifies the aggressive position size adjustments without loops
if (not na(initialEntryPrice))
    if (close < initialEntryPrice * 0.995) // 0.5% drop from initial entry
        strategy.entry("Martingale Buy 1", strategy.long, qty=((strategy.equity * initialInvestmentPercent / 100) / close) * 2)
        multiplier := 2 // Adjusting multiplier for the next potential entry

    if (close < initialEntryPrice * 0.990) // Further drop
        strategy.entry("Martingale Buy 2", strategy.long, qty=((strategy.equity * initialInvestmentPercent / 100) / close) * 4)
        multiplier := 4

    // Additional conditional entries could follow the same pattern

// Checking for profit target to close positions
if (strategy.position_size > 0 and (close - strategy.position_avg_price) / strategy.position_avg_price >= profitTargetPercent)
    strategy.close_all(comment="Take Profit")
    initialEntryPrice := na // Reset for next cycle


더 많은