MACD 역전 전략의 RSI

저자:차오장, 날짜: 2024-01-15 12:33:14
태그:

img

전반적인 설명

이 전략은 매크드 지표의 RSI 값을 기반으로 구매 및 판매 신호를 결정합니다. RSI가 과잉 구매 라인이나 범위를 초과 할 때 구매하고, RSI가 과잉 구매 범위를 넘으면 수익 / 손실을 판매하거나 중지합니다.

전략 원칙

이 전략은 MACD와 RSI의 장점을 결합합니다.

먼저 MACD 지표의 3개의 곡선이 계산됩니다. DIF, DEA 및 MACD 라인을 포함하여. 그 다음 RSI 지표는 MACD 라인에 계산되어 MACD의 RSI를 형성합니다.

MACD 지표의 RSI가 30 또는 35의 과잉 구매 범위를 초과하면 MACD 라인이 과잉 판매 범위에 들어갔고 가격 추세가 상승세를 타기 시작했다는 것을 나타내는 구매 신호가 생성됩니다. MACD 지표의 RSI가 다시 15의 과잉 구매 범위를 넘으면 트렌드 반전이 끝났다는 것을 나타내는 판매 신호가 생성됩니다.

이 전략은 또한 부분 수익을 설정합니다. MACD 지표의 RSI가 80의 과잉 매수 수준을 초과하면 부분 수익을 확보하기 위해 위치의 일부가 판매 될 수 있습니다.

이점 분석

  • 트렌드 반전 지점을 결정하기 위해 MACD 지표를 사용하십시오.
  • 가짜 신호를 필터링하기 위해 과반 구매/ 과반 판매 수준을 결정하기 위해 RSI 지표를 사용
  • 정확한 구매/판매 지점을 위한 이중 지표의 조합
  • 손실 증가를 방지하기 위한 부분적 이익 취득

위험 분석

  • MACD 매개 변수 부적절한 경우 트렌드의 부정확한 판단
  • 부적절한 RSI 매개 변수인 경우 과잉 구매/ 과잉 판매 구역의 부정확한 판단
  • 수익이 너무 공격적이면 더 큰 상승률을 놓칠 수 있습니다.

해결책:

  • 최고의 조합을 찾기 위해 MACD 매개 변수를 최적화
  • 정확성을 높이기 위해 RSI 매개 변수를 최적화
  • 더 큰 수익을 목표로 수익을 취하는 기준을 적절히 완화하십시오.

최적화 방향

이 전략은 다음 측면에서도 최적화 될 수 있습니다.

  1. 하향 리스크를 더 통제하기 위해 스톱 로스 전략을 추가합니다.
  2. 포지션 사이징 모듈을 추가하여 가격 변동에 따라 점진적으로 포지션을 증가시킵니다.
  3. 구매/판매 포인트 정확성을 더 향상시키기 위해 역사 데이터에 훈련된 기계 학습 모델을 통합
  4. 전략의 빈도를 향상시키기 위해 15m 또는 5m와 같은 짧은 시간 프레임에서 실행 시도

결론

전반적인 전략 설계 철학은 명확하며, 구매/판매 포인트를 결정하기 위해 MACD 역전을 RSI 필터와 결합하여 사용하는 핵심 아이디어입니다. 매개 변수 최적화, 스톱 로스 관리, 위험 관리 조치 등으로 매우 실용적인 양 거래 전략으로 형성 될 수 있습니다.


/*backtest
start: 2024-01-07 00:00:00
end: 2024-01-14 00:00:00
period: 3m
basePeriod: 1m
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/
// © mohanee

//@version=4

strategy(title="RSI of MACD Strategy[Long only]",  shorttitle="RSIofMACD" , overlay=false, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  //default_qty_value=10, default_qty_type=strategy.fixed,

	

/////////////////////////////////////////////////////////////////////////////////



// MACD Inputs ///
fastLen = input(12, title="Fast Length")
slowLen = input(21, title="Slow Length")
sigLen  = input(9, title="Signal Length")

rsiLength  = input(14, title="RSI of MACD Length")




riskCapital = input(title="Risk % of capital", defval=10, minval=1)
stopLoss=input(3,title="Stop Loss",minval=1)

takeProfit=input(false, title="Take Profit")


[macdLine, signalLine, _] = macd(close, fastLen, slowLen, sigLen)

rsiOfMACD = rsi(macdLine, rsiLength)
emaSlow = ema(close, slowLen)



//drawings
/////////////////////////////////////////////////////////////////////////////////


obLevelPlot = hline(80, title="Overbought / Profit taking line",  color=color.blue , linestyle=hline.style_dashed)
osLevelPlot = hline(30, title="Oversold / entry line", color=color.green, linestyle=hline.style_dashed)

exitLinePlot = hline(15, title="Exit line", color=color.red, linestyle=hline.style_dashed)




plot(rsiOfMACD, title = "rsiOfMACD" ,  color=color.purple)


//drawings
/////////////////////////////////////////////////////////////////////////////////




//Strategy Logic 
/////////////////////////////////////////////////////////////////////////////////

//Entry--
//Echeck how many units can be purchased based on risk manage ment and stop loss
qty1 = (strategy.equity  * riskCapital / 100 ) /  (close*stopLoss/100)  

//check if cash is sufficient  to buy qty1  , if capital not available use the available capital only
qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1


strategy.entry(id="RSIofMACD", long=true,   qty=qty1,  when =  ( crossover(rsiOfMACD, 30) or crossover(rsiOfMACD, 35)  ) and close>=emaSlow )



bgcolor(abs(strategy.position_size)>=1 ? color.blue : na , transp=70)


barcolor(abs(strategy.position_size)>=1 and  ( crossover(rsiOfMACD, 30) or crossover(rsiOfMACD, 35) ) ? color.purple : abs(strategy.position_size)>=1 ? color.blue : na  )


//partial exit
strategy.close(id="RSIofMACD", comment="PExit Profit is "+tostring(close - strategy.position_avg_price,  "###.##")  ,  qty=strategy.position_size/3, when= takeProfit and abs(strategy.position_size)>=1 and close > strategy.position_avg_price and crossunder(rsiOfMACD,80) )

//Close All
strategy.close(id="RSIofMACD", comment="Close All   Profit is "+tostring(close - strategy.position_avg_price,  "###.##"), when=abs(strategy.position_size)>=1 and crossunder(rsiOfMACD,15) ) //and close > strategy.position_avg_price )


//Strategy Logic 
/////////////////////////////////////////////////////////////////////////////////



더 많은