이 전략은 1분 MACD 지표와 RSI 지표의 설계에 기반한 단선 돌파 전략이다. MACD 지표의 추세를 판단하고 돌파구를 찾는 것과 RSI 지표의 오버 바이 오버 셀을 판단하고, 짧은 선을 돌파하는 기회를 찾아 장단한 움직임을 하는 능력을 결합한다.
이 전략은 먼저 1분 시간 프레임에 MACD 지표의 분산선을 계산하고, 브린띠의 분산선을 판단하는 돌파구를 그려낸다. 동시에 RSI 지표의 다공력로를 판단하는 RSI 지표를 계산한다. 브린띠, MACD 및 RSI 지표가 동시에 조건을 충족할 때만 거래 신호를 낸다.
구체적으로, 1분 MACD 집약선이 하향 궤도보다 낮고 RSI가 51보다 높을 때 더 많이 하고, MACD 집약선이 상향 궤도보다 높고 RSI가 49보다 낮을 때 공백을 한다. 그리고 9일, 50일, 200일 평균선 순차적 배열을 요구하여 거래할 수 있도록 하여 불리한 경향 역전 운영을 막는다.
고정된 스톱 스톱 손실 Exit 이익이 0.5%에 도달하거나 손실이 0.3%에 도달했을 때 청산한다.
이 전략은 트렌드 판단과 오버 바이 오버 세일 판단을 결합하여 가짜 브레이크를 효과적으로 필터링 할 수 있습니다. 고정된 스톱 스톱 손실은 각 수익에 대한 일정 기대 관리를 제공합니다.
장점은 다음과 같습니다.
MACD는 트렌드 방향을 판단하고, RSI는 다공력 경로를 판단하여 역동작전을 효과적으로 피할 수 있다.
브린带通道과 결합하여 돌파 신호를 판단하여 가짜 돌파를 필터링할 수 있다.
고정된 스톱 스톱 손실을 취하고, 각 수익에 대해 일정한 기대를 가지고, 단독 손실을 제어할 수 있다.
거래 빈도가 높기 때문에 단선 운영에 적합하다.
이 전략에는 몇 가지 위험도 있습니다.
고정 스톱 스톱 손실은 시장 변화에 따라 조정할 수 없으며, 스톱 손실이 너무 작거나 스톱 스톱 손실이 너무 커질 수 있습니다.
지표에 따라 여러 개의 필터링 신호가 발생하고, 정렬 영역에서 여러 개의 스톱 손실이 발생한다.
높은 주파수 거래 수수료 부담이 큽니다.
MACD와 RSI의 변수는 최적화가 필요하며, 현재 변수는 최적화되지 않을 수 있습니다.
다음의 몇가지가 더 개선될 수 있습니다.
동적 스톱 스톱 손실을 사용하여 ATR과 같은 지표에 따라 스톱 스톱 손실 비율을 조정합니다.
브린 대역변수를 키우면 통로를 좁히고, 발사 빈도를 낮출 수 있다.
MACD와 RSI 변수를 최적화하여 최적의 변수 조합을 찾습니다.
대주기 트렌드 방향에 따라 필터링하여 역동적인 거래를 피하십시오.
이 전략은 전체적으로 전형적인 단선 돌파 시스템으로, 트렌드, 오버 바이 오버 셀 판단을 통합하여 단선 기회를 효과적으로 발견할 수 있다. 그러나 특정 위험이 존재하고, 추가 테스트 및 최적화 파라미터가 필요하며, 위험을 줄여 수익률을 높인다. 파라미터가 적절하게 조정되면, 이 전략은 효율적인 단선 전략 중 하나가 될 수 있다.
/*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)