MACD RSI 단기 브레이크업 전략

저자:차오장, 날짜: 2023-10-07 16:08:53
태그:

전반적인 설명

이것은 1분 MACD 지표와 RSI 지표에 기반한 단기 브레이크업 전략입니다. 트렌드를 결정하고 브레이크업 포인트를 찾고 RSI를 결합하여 과잉 구매 및 과잉 판매 조건을 판단하고 장기 및 단기 스칼핑의 단기 브레이크업 기회를 찾습니다.

전략 논리

이 전략은 먼저 MACD 히스토그램을 1분 시간 프레임에서 계산하고, 볼링거 밴드를 그래프화하여 히스토그램 브레이크아웃 상황을 결정한다. 동시에, RSI 인디케이터를 계산하여 긴 및 짧은 모멘텀을 결정한다. 볼링거 밴드, MACD 및 RSI 인디케이터가 모두 동시에 기준을 충족할 때만 거래 신호가 트리거된다.

구체적으로, 1분 MACD 히스토그램이 하위 밴드 아래와 RSI가 51보다 높을 때 장을 하고, MACD 히스토그램이 상위 밴드 위에 있고 RSI가 49보다 낮을 때 단장을 합니다. 또한, 불리한 트렌드 트레이딩을 피하기 위해 9일, 50일 및 200일 이동 평균이 거래 전에 순서대로 있어야 합니다.

이윤을 취하고 손실을 멈추는 고정 출구를 취합니다. 이윤이 0.5%에 도달하거나 손실이 0.3%에 도달하면 위치를 닫습니다.

이점 분석

이 전략은 트렌드 판단과 과잉 구매/ 과잉 판매 판단을 결합하여 잘못된 브레이크오프를 효과적으로 필터링할 수 있습니다. 고정된 TP/SL는 모든 거래가 특정 수익 기대 관리에 의해 이루어집니다.

이점은 다음과 같습니다.

  1. MACD는 트렌드 방향을 판단하고 RSI는 장기/단기 모멘텀을 판단하여 트렌드에 반대하는 거래를 효과적으로 피할 수 있습니다.

  2. 브레이크오웃 신호를 판단하기 위해 볼링거 밴드를 결합하면 가짜 브레이크오웃을 필터링할 수 있습니다.

  3. 일정한 TP/SL를 채택하면 모든 거래는 특정 수익 기대를 가지고 있으며 이는 단일 거래 손실을 제어합니다.

  4. 거래 빈도는 높고, 단기 거래에 적합합니다.

위험 분석

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

  1. 고정 TP/SL는 시장 변화에 따라 조정할 수 없으며 SL가 너무 작고 TP가 너무 커질 수 있습니다.

  2. 그것은 여러 개의 필터 신호에 의존하고 있으며, 이는 범위 제한 시장에서 여러 SL를 유발할 수 있습니다.

  3. 높은 거래 빈도는 높은 수수료로 이어집니다.

  4. MACD 및 RSI 매개 변수는 추가 최적화가 필요하며 현재 매개 변수는 최적화되지 않을 수 있습니다.

다음 측면은 더 이상 최적화 될 수 있습니다:

  1. 동적 TP/SL를 채택하고, ATR 등을 기준으로 비율을 조정합니다.

  2. 볼링거 대역을 넓혀서 채널을 좁히고, 트리거 주파수를 낮춰요.

  3. MACD와 RSI 매개 변수를 최적화하여 최적의 조합을 찾습니다.

  4. 트렌드에 반대되는 거래를 피하기 위해 더 높은 시간 프레임 트렌드에 기반한 필터.

요약

전체적으로 이 전략은 트렌드, 모멘텀 및 과잉 매수/ 과잉 판매 분석을 통합한 전형적인 단기 브레이크아웃 시스템으로, 단기 기회를 효과적으로 발견할 수 있다. 그러나 특정 위험이 있으며, 위험을 낮추고 수익성을 향상시키기 위해 추가 테스트와 매개 변수 최적화를 필요로 한다. 적절하게 조정되면 이 전략은 효율적인 단기 거래 전략이 될 수 있다.


/*backtest
start: 2023-09-06 00:00:00
end: 2023-10-06 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/
// © pluckyCraft54926

//@version=5
strategy("5 Minute Scalp", overlay=true, margin_long=100, margin_short=100)

fast_length = input(title="Fast Length", defval=12)
slow_length = input(title="Slow Length", defval=26)
src = input(title="Source", defval=close)
signal_length = input.int(title="Signal Smoothing",  minval = 1, maxval = 50, defval = 9)
sma_source = input.string(title="Oscillator MA Type",  defval="EMA", options=["SMA", "EMA"])
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])
// Plot colors
col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD")
col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal")
col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
hist_1m = request.security(syminfo.tickerid,"1",hist [barstate.isrealtime ? 1 : 0])
hline(0, "Zero Line", color=color.new(#787B86, 50))
////////////////////////////////////////////////////
//plotting emas on the chart
len1 = input.int(9, minval=1, title="Length")
src1 = input(close, title="Source")
offset1 = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out1 = ta.ema(src1, len1)
plot(out1, title="EMA9", color=color.blue, offset=offset1)

len2 = input.int(50, minval=1, title="Length")
src2 = input(close, title="Source")
offset2 = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out2 = ta.ema(src2, len2)
plot(out2, title="EMA50", color=color.yellow, offset=offset2)

len3 = input.int(200, minval=1, title="Length")
src3 = input(close, title="Source")
offset3 = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out3 = ta.ema(src3, len3)
plot(out3, title="EMA200", color=color.white, offset=offset3)
//////////////////////////////////////////////////////////////////
//Setting up the BB
/////////////////////////////////////////////////////////////
srcBB = hist_1m
lengthBBLong = input.int(94,title = "LengthBB Long", minval=1)
lengthBBShort = input.int(83,title = "LengthBB Short", minval=1)
multBB = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basisBBLong = ta.sma(srcBB, lengthBBLong)
basisBBShort = ta.sma(srcBB, lengthBBShort)
devBBLong = multBB * ta.stdev(srcBB, lengthBBLong)
devBBShort = multBB * ta.stdev(srcBB, lengthBBShort)
upperBB = basisBBShort + devBBShort
lowerBB = basisBBLong - devBBLong
offsetBB = input.int(0, "Offset", minval = -500, maxval = 500)

/////////////////////////////////////////
//aetting up rsi
///////////////////////////////////////////
rsilengthlong = input.int(defval = 11, title = "Rsi Length Long", minval = 1)
rlong=ta.rsi(close,rsilengthlong)
rsilengthshort = input.int(defval = 29, title = "Rsi Length Short", minval = 1)
rshort=ta.rsi(close,rsilengthshort)
///////////////////////////
//Only taking long and shorts, if RSI is above 51 or bellow 49
rsilong = rlong >= 51
rsishort = rshort <= 49
//////////////////////////////////////
//only taking trades if all 3 emas are in the correct order
long = out1 > out2 and out2 > out3
short = out1 < out2 and out2 < out3
/////////////////////////////////////


///////////////////////////////////////////
//setting up TP and SL
TP = input.float(defval = 0.5, title = "Take Profit %",step = 0.1) / 100
SL = input.float(defval = 0.3, title = "Stop Loss %", step = 0.1) / 100

longCondition = hist_1m <= lowerBB
longhight = input(defval=-10,title = "MacdTick Low")
if (longCondition and long and rsilong and hist_1m <= longhight) 
    strategy.entry("Long", strategy.long)

if (strategy.position_size>0)
    longstop = strategy.position_avg_price * (1-SL)
    longprofit = strategy.position_avg_price * (1+TP)
    strategy.exit(id ="close long",from_entry="Long",stop=longstop,limit=longprofit)

shortCondition = hist_1m >= upperBB
shorthight = input(defval=35,title = "MacdTick High")
if (shortCondition and short and rsishort and hist_1m >= shorthight)
    strategy.entry("short ", strategy.short)

shortstop = strategy.position_avg_price * (1+SL)
shortprofit = strategy.position_avg_price * (1-TP)

if (strategy.position_size<0)
    strategy.exit(id ="close short",stop=shortstop,limit=shortprofit)





더 많은