SRSI 및 MACD 지능형 위험 관리 시스템과 결합된 동적 적응형 다중 지표 교차 전략

RSI SRSI MACD ATR
생성 날짜: 2025-02-20 13:07:37 마지막으로 수정됨: 2025-02-27 17:44:09
복사: 1 클릭수: 329
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

SRSI 및 MACD 지능형 위험 관리 시스템과 결합된 동적 적응형 다중 지표 교차 전략 SRSI 및 MACD 지능형 위험 관리 시스템과 결합된 동적 적응형 다중 지표 교차 전략

개요

이 전략은 무작위적으로 상대적으로 약한 지표 ((SRSI) 와 이동 평균 동향/분산 지표 ((MACD) 를 결합한 동적 거래 시스템이다. ATR 지표를 통해 스톱로스와 스톱포트를 동적으로 조정하여 위험에 대한 지능적인 관리를 구현한다. 이 전략의 핵심은 다중 기술 지표의 교차 확인을 통해 거래 신호를 생성하는 것과 동시에 시장의 변동성을 결합하여 포지션 관리를 수행하는 것이다.

전략 원칙

이 전략은 다음과 같은 핵심 메커니즘을 기반으로 작동합니다.

  1. SRSI 지표의 K선과 D선, 그리고 K선과 통합 MACD의 차이를 계산하여 시장 흐름을 판단합니다.
  2. 구매 조건이 동시에 충족되어야 합니다: K-D 차이는 긍정적이고, K-MACD 차이는 긍정적이며, MACD는 하락 추세에 있지 않습니다.
  3. 판매 조건이 동시에 충족되어야 합니다: K-D 차이는 마이너스, K-MACD 차이는 마이너스, 그리고 MACD는 상승 추세에 있지 않습니다
  4. ATR을 사용하여 위험 계수를 동적으로 사용하여 시장의 변동성에 따라 조정되는 스톱로즈 및 스톱 거리 계산

전략적 이점

  1. 다중 신호 확인 메커니즘은 거래의 신뢰성을 크게 향상시키고 단일 지표로 인해 발생할 수있는 잘못된 신호를 방지합니다.
  2. 동적 스톱 스톱 설정은 시장의 변동에 따라 자동으로 조정할 수 있으며, 더 나은 위험-수익 비율을 제공합니다.
  3. 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 수 있는 잘 적응
  4. 변수는 조정 가능하며 개인 위험 선호도에 따라 최적화 할 수 있습니다.

전략적 위험

  1. 불안한 시장에서 과도한 거래 신호가 발생할 수 있으며, 이는 시장의 출입을 유도합니다.
  2. 다중 지표의 사용은 신호를 지연시킬 수 있으며, 빠르게 변화하는 시장에서 최적의 진입 시기를 놓칠 수 있습니다.
  3. ATR은 역사적인 변동성을 기반으로 하고 시장 변동성에 따라 적절하게 대응할 수 없습니다.
  4. 너무 크거나 너무 작거나 전략의 효과에 영향을 미칠 수 있는 합리적인 위험 인자를 설정해야 합니다.

전략 최적화 방향

  1. 트렌드 필터를 추가하고, 흔들림 시장과 트렌드 시장에서 다른 신호 확인 기준을 사용합니다.
  2. 신호의 신뢰성을 높이기 위해 보조 확인으로 통행량 지표를 도입
  3. 스탠드 손실 스톱을 최적화 하는 계산 방법, 지원 저항 지점과 함께 고려할 수 있다
  4. 시장 변동률 예측 모형에 참여하여 위험 요소를 미리 조정합니다.
  5. 다양한 시간대에서 신호를 확인하는 것을 고려하여 전략의 안정성을 높여라

요약하다

이 전략은 SRSI와 MACD의 장점을 결합하여 안정적인 거래 시스템을 구축한다. 동적 위험 관리 메커니즘은 이를 잘 적응하게 하지만 여전히 거래자가 실제 시장 상황에 따라 매개 변수를 최적화해야 한다. 전략의 성공적인 운영은 시장에 대한 깊은 이해가 필요하며, 개인의 위험 감수 능력과 함께 합리적인 위치 관리를 수행한다.

전략 소스 코드
/*backtest
start: 2024-09-01 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

//@version=6
strategy(title="SRSI + MACD Strategy with Dynamic Stop-Loss and Take-Profit", shorttitle="SRSI + MACD Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// User Inputs
smoothK = input.int(3, "K", minval=1) 
smoothD = input.int(3, "D", minval=1) 
lengthRSI = input.int(16, "RSI Length", minval=1) 
lengthStoch = input.int(16, "Stochastic Length", minval=1) 
src = input(close, title="RSI Source") 
enableStopLoss = input.bool(true, "Enable Stop-Loss")  
enableTakeProfit = input.bool(true, "Enable Take-Profit")  
riskFactor = input.float(2.5, "Risk Factor", minval=0.1, step=1)  

// Calculate K and D lines
rsi1 = ta.rsi(src, lengthRSI) 
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK) 
d = ta.sma(k, smoothD) 
differenceKD = k - d 

// Calculate MACD and normalization
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9) 
lowestK = ta.lowest(k, lengthRSI) 
highestK = ta.highest(k, lengthRSI) 
normalizedMacd = (macdLine - ta.lowest(macdLine, lengthRSI)) / (ta.highest(macdLine, lengthRSI) - ta.lowest(macdLine, lengthRSI)) * (highestK - lowestK) + lowestK 
differenceKMacd = k - normalizedMacd 

// Sum both differences for a unique display
differenceTotal = (differenceKD + differenceKMacd) / 2

// Check if MACD is falling or rising
isMacdFalling = ta.falling(macdLine, 1)  
isMacdRising = ta.rising(macdLine, 1)  

// Check if K is falling or rising
isKFalling = ta.falling(k, 1)  
isKdRising = ta.rising(k, 1)  

// Calculate ATR and dynamic levels
atrValue = ta.atr(14)  
stopLossDistance = atrValue * riskFactor  
takeProfitDistance = atrValue * riskFactor  

// Variables for stop-loss and take-profit levels
var float longStopPrice = na
var float longTakeProfitPrice = na

// Buy and sell conditions with differenceKD added
buyCondition = ((differenceTotal > 0 or differenceKD > 0) and (isKdRising or isMacdRising) and k < 20 )  
sellCondition = ((differenceTotal <= 0 or differenceKD <= 0) and (isKFalling or isMacdFalling) and k > 80)  

// Execute strategy orders with conditional stop-loss and take-profit
if buyCondition and strategy.position_size == 0
    strategy.entry("Buy", strategy.long)

if strategy.position_size > 0
    longStopPrice := strategy.position_avg_price - stopLossDistance  
    longTakeProfitPrice := strategy.position_avg_price + takeProfitDistance  

    if enableStopLoss or enableTakeProfit
        strategy.exit("Sell/Exit", "Buy", stop=(enableStopLoss ? longStopPrice : na), limit=(enableTakeProfit ? longTakeProfitPrice : na))

if sellCondition
    strategy.close("Buy")  

// Hide lines when position is closed
stopLossToPlot = strategy.position_size > 0 ? longStopPrice : na
takeProfitToPlot = strategy.position_size > 0 ? longTakeProfitPrice : na

// Plot stop-loss and take-profit lines only when long positions are active
plot(enableStopLoss ? stopLossToPlot : na, title="Stop-Loss", color=color.yellow, linewidth=1, style=plot.style_linebr, offset=0, force_overlay=true) 
plot(enableTakeProfit ? takeProfitToPlot : na, title="Take-Profit", color=color.yellow, linewidth=1, style=plot.style_linebr, offset=0, force_overlay=true)

// Plot the MACD and candles

plot(normalizedMacd, "Normalized MACD", color=color.new(color.purple, 0), linewidth=1, display=display.all)

h0 = hline(80, "Upper Band", color=#787B86) 
hline(50, "Middle Band", color=color.new(#787B86, 50)) 
h1 = hline(20, "Lower Band", color=#787B86) 
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")

// New candle based on the sum of differences
plotcandle(open=0, high=differenceTotal, low=0, close=differenceTotal, color=(differenceTotal > 0 ? color.new(color.green, 60) : color.new(color.red, 60)), title="K-D + MACD Candles")