이 전략은 빠른 평균선과 느린 평균선의 조합을 사용하여 트렌드 방향을 판단하고, 중장선 트렌드를 포착하기 위해 트렌드 거래를 한다. 빠른 평균선 위에 느린 평균선을 통과할 때 더 많이 하고, 빠른 평균선 아래에 느린 평균선을 통과할 때 공백을 하는 것은 전형적인 트렌드 추적 전략이다.
이 전략은 주로 평행선의 황금 포크 데드 포크에 의존하여 시장의 추세를 판단한다. 구체적으로, 전략은 5주기의 빠른 평균선과 21주기의 느린 평균선을 사용합니다.
빠른 평균선 위에 느린 평균선을 통과하면, 시장 추세가 더 많이 변하는 것을 의미하며, 이 전략은 다음 K 선 개시 시에 더 많이 할 것입니다. 빠른 평균선 아래에서 느린 평균선을 통과하면, 시장 추세가 역전되는 것을 의미하며, 이 전략은 다음 K 선 개시 시에 공백을 할 것입니다.
또한, 전략은 bars 파라미터를 파크를 필터링하기 위해 설정한다. 이 파라미터는 기본값이 2이다. 즉, 빠른 평균선은 2개의 연속적인 K 선이 느린 평균선 위에 더 많은 신호를 발산하기 전에 효과적으로 파크를 필터링 할 수 있다.
암호화폐의 경우, 전략에는 극한값 판단 논리도 추가되었다. 빠른 평균선과 느린 평균선이 동시에 극한 영역에 있을 때만 거래 신호를 발산한다. 이것은 또한 가짜 돌파구를 추가적으로 방지하기 위한 것이다.
전략적 탈퇴 규칙은 간단하고 직설적입니다. 가격이 스톱로스를 터치하면 현재 포지션을 탈퇴합니다.
위험은 다음과 같은 방법으로 줄일 수 있습니다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
더 많은 조합을 테스트하여 현재 시장에 더 적합한 평균선 변수를 찾을 수 있습니다. 예를 들어, 빠른 라인을 10주기, 느린 라인을 50주기로 조정하십시오.
MACD, KDJ 등의 다른 지표를 추가하여 테스트할 수 있으며, 가짜 돌파구를 피하기 위해 더 엄격한 조건을 설정할 수 있다.
현재 입학은 너무 단순하게 평균선에 의존하고 있으며, 다음과 같이 최적화할 수 있습니다:
가격 추적 스톱처럼 다른 스톱 방법을 테스트 할 수 있습니다. 스톱이 너무 일찍 촉발되는 것을 피하기 위해.
포지션이 종료된 후 다시 입장이 가능해져, 현장에서 멈추고 트렌드를 놓치는 경우가 줄어들 수 있다.
이 전략은 기본 트렌드 추적 전략으로, 핵심 아이디어는 간단하고 직접적이며, 트렌드 방향을 판단하는 쌍평평선과 이동 스톱을 사용하여 위험을 제어합니다. 장점은 이해하기 쉽고 구현할 수 있으며, 추세에 따라 수익을 얻을 수 있으며, 위험도 제어 할 수 있습니다. 그러나 동시에 몇 가지 결함이 있습니다. 시세 시장에서 신호가 정확하지 않으며, 스톱은 너무 일찍 유발 될 수 있습니다. 이것은 우리가 시세에서 지속적으로 최적화를 조정하고 다른 기술 지표에 필터를 추가하여 전략을 다른 시장 환경에 더 적합하게합니다.
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy(title = "Noro's Trend MAs Strategy v2.3", shorttitle = "Trend MAs str 2.3", 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, %")
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?")
needex = input(true, defval = true, title = "Need extreme? (crypto/fiat only!!!)")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
src = 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)
//Signals
up1 = trend == 1 and (low < center2 or usefastsma == false) and redbars == 1
dn1 = trend == -1 and (high > center2 or usefastsma == false) and greenbars == 1
up2 = high < center and high < center2 and bar == -1 and needex
dn2 = low > center and low > center2 and bar == 1 and needex
up3 = close < open and len > sma * 3 and min < min[1] and fastrsi < 10 ? 1 : 0
//Lines
plot(center2, color = red, linewidth = 3, transp = 0, title = "Fast MA")
plot(center, color = blue, linewidth = 3, transp = 0, title = "Slow MA")
//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 80)
//Trading
stoplong = up1 == 1 and needstops == true ? close - (close / 100 * stoppercent) : stoplong[1]
stopshort = dn1 == 1 and needstops == true ? close + (close / 100 * stoppercent) : stopshort[1]
if up1 or up2 or up3
strategy.entry("Long", strategy.long, needlong == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
strategy.exit("Stop Long", "Long", stop = stoplong)
if dn1
strategy.entry("Short", strategy.short, needshort == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
strategy.exit("Stop Short", "Short", stop = stopshort)
if time > timestamp(toyear, tomonth, today, 23, 59)
strategy.close_all()