
이중 MA 흐름 돌파 전략은 두 개의 다른 주기의 이동 평균을 사용하여 트렌드 판단과 입장을 결정하는 양적 거래 전략이다. 전략은 주로 느린 MA를 통해 전체적인 트렌드 방향을 판단하고, 빠른 MA를 사용하여 입장을 필터링하며, 큰 차원의 트렌드 방향이 일치하면 K선을 반전하여 입장을 선택하여 더 높은 승률과 수익률을 추구한다.
이 전략은 다음과 같은 부분들로 구성됩니다.
트렌드 판단:21주기의 MA를 계산하여, 느린 MA로 정의하고, 그 위치가 평평한 경우, 전체 트렌드 방향을 판단하는 데 사용할 수 있습니다. 가격이 상승할 때 MA 값에 가까워지면 상승 트렌드이며, 가격이 떨어질 때 MA 값에 가까워지면 하락 트렌드입니다.
입국 필터:5주기 MA를 계산하고, 빠른 MA로 정의한다. 가격이 느린 MA를 돌파하면서 동시에 빠른 MA를 돌파할 때만 거래 신호가 발생한다. 이 디자인은 주로 가짜 돌파의 가능성을 추가로 필터링한다.
K선 필터:이 전략은 이 주기의 K선이 음선일 때만 더 많이 하거나, 이 주기의 K선이 양선일 때만 공백하게 한다. 이것은 반전 K선으로 입문하면 더 높은 성공률을 얻을 수 있다는 점을 고려한 것이다. 동시에 빠른 RSI 지표와 결합하여 과도한 오버 바이 또는 오버 셀 영역에 입문하는 것을 피한다.
가축 필터:암호화폐 시장의 경우, 전략은 추가적으로 3배의 변동성 돌파구 가설 조건을 추가하여, 대규모 하락 과정에서 초하락 기회를 가한다.
손해 방지 디자인:전략은 모바일 스톱을 지원한다. 포지션을 열었을 때, 설정된 스톱 비율에 따라 실시간으로 스톱 위치를 업데이트한다.
이 전략은 다음과 같은 장점을 가지고 있습니다.
이 전략에는 몇 가지 위험도 있습니다.
이러한 위험에는 다음과 같은 측면에서 최적화할 수 있습니다.
이 전략은 다음의 몇 가지 측면에서 최적화될 수 있습니다.
변수 최적화: 더 체계적인 회전으로, 빠른 느린 MA의 주기적 파라미터 조합을 최적화하여 전체적인 수익 위험 비율을 향상시킨다.
패턴 인식: KDJ, MACD와 같은 다른 지표를 추가하여 더 신뢰할 수 있는 역전 신호를 식별한다.
손해 방지 최적화: 플로잉 스톱, 스톱 추적 등의 알고리즘을 개발하여 스톱이 유발되는 확률을 낮출 수 있다.
기계 학습: 더 많은 역사 데이터를 수집하고 표기하고, 기계 학습 방법을 사용하여 거래 규칙을 자동으로 생성한다.
양적 전환: 시장 상황에 따라 자동으로 포지션 관리 전략을 조정한다.
이중 MA 순차 돌파 전략은 전반적으로 비교적 간단하고 실용적인 트렌드 추적 전략이다. 복잡한 기계 학습 알고리즘에 비해 이 전략은 더 쉽게 해석하고 숙지할 수 있으며 신뢰도도 높다. 매개 변수 최적화, 기능 확장 및 기계 학습의 도입으로 이 전략은 큰 개선 잠재력을 가지고 있으며, 양적 거래에 좋은 출발점이다.
/*backtest
start: 2023-12-31 00:00:00
end: 2024-01-07 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy(title = "Noro's Trend MAs Strategy v2.0 +CB", shorttitle = "Trend MAs str 2.0", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)
//Settings
needlong = input(true, "long")
needshort = input(true, "short")
needstops = input(false, "stops")
stoppercent = input(5, defval = 5, minval = 1, maxval = 50, title = "Stop, %")
useohlc4 = input(false, defval = false, title = "Use OHLC4")
usefastsma = input(true, "Use fast MA Filter")
fastlen = input(5, defval = 5, minval = 1, maxval = 50, title = "fast MA Period")
slowlen = input(21, defval = 20, minval = 2, maxval = 200, title = "slow MA Period")
bars = input(2, defval = 2, minval = 0, maxval = 3, title = "Bars Q")
needbg = input(false, defval = false, title = "Need trend Background?")
needarr = input(false, defval = false, title = "Need entry arrows?")
needex = input(true, defval = true, title = "Need extreme? (crypto/fiat only!!!)")
src = useohlc4 == true ? ohlc4 : close
//PriceChannel 1
lasthigh = highest(src, slowlen)
lastlow = lowest(src, slowlen)
center = (lasthigh + lastlow) / 2
//PriceChannel 2
lasthigh2 = highest(src, fastlen)
lastlow2 = lowest(src, fastlen)
center2 = (lasthigh2 + lastlow2) / 2
//Trend
trend = low > center and low[1] > center[1] ? 1 : high < center and high[1] < center[1] ? -1 : trend[1]
//Bars
bar = close > open ? 1 : close < open ? -1 : 0
redbars = bars == 0 ? 1 : bars == 1 and bar == -1 ? 1 : bars == 2 and bar == -1 and bar[1] == -1 ? 1 : bars == 3 and bar == -1 and bar[1] == -1 and bar[2] == -1 ? 1 : 0
greenbars = bars == 0 ? 1 : bars == 1 and bar == 1 ? 1 : bars == 2 and bar == 1 and bar[1] == 1 ? 1 : bars == 3 and bar == 1 and bar[1] == 1 and bar[2] == 1 ? 1 : 0
//Fast RSI
fastup = rma(max(change(close), 0), 2)
fastdown = rma(-min(change(close), 0), 2)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))
//CryptoBottom
mac = sma(close, 10)
len = abs(close - mac)
sma = sma(len, 100)
max = max(open, close)
min = min(open, close)
up3 = close < open and len > sma * 3 and min < min[1] and fastrsi < 10 ? 1 : 0
//Signals
up = trend == 1 and (low < center2 or usefastsma == false) and (redbars == 1) ? 1 : 0
dn = trend == -1 and (high > center2 or usefastsma == false) and (greenbars == 1) ? 1 : 0
up2 = high < center and high < center2 and bar == -1 ? 1 : 0
dn2 = low > center and low > center2 and bar == 1 ? 0 : 0
//Lines
plot(center, color = blue, linewidth = 3, transp = 0, title = "Slow MA")
plot(center2, color = red, linewidth = 3, transp = 0, title = "PriceChannel 2")
//Arrows
plotarrow(up == 1 and needarr == true ? 1 : 0, colorup = black, colordown = black, transp = 0)
plotarrow(dn == 1 and needarr == true ? -1 : 0, colorup = black, colordown = black, transp = 0)
//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 90)
//Alerts
alertcondition(up == 1, title='buy', message='Uptrend')
alertcondition(dn == 1, title='sell', message='Downtrend')
//Trading
stoplong = up == 1 and needstops == true ? close - (close / 100 * stoppercent) : stoplong[1]
stopshort = dn == 1 and needstops == true ? close + (close / 100 * stoppercent) : stopshort[1]
longCondition = up == 1 or (up2 == 1 and needex == true) or up3 == 1
if (longCondition)
strategy.entry("Long", strategy.long, needlong == false ? 0 : na)
strategy.exit("Stop Long", "Long", stop = stoplong)
shortCondition = dn == 1
if (shortCondition)
strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
strategy.exit("Stop Short", "Short", stop = stopshort)