슈퍼트렌드 추종 전략


생성 날짜: 2023-12-26 15:58:55 마지막으로 수정됨: 2023-12-26 15:58:55
복사: 1 클릭수: 611
avatar of ChaoZhang ChaoZhang
1
집중하다
1623
수행원

슈퍼트렌드 추종 전략

개요

이 전략은 추적형의 슈퍼 트렌드 전략으로, 주요 아이디어는 다양한 파라미터 설정을 결합한 슈퍼 트렌드 지표를 사용하여 추적 효과를 달성하고 필터 지표를 사용하여 위험을 제어하는 것입니다. 전략의 핵심 아이디어는 간단하고 실용적이며, 이해하기 쉽고, 초보자 학습에 적합합니다.

전략 원칙

이 전략은 주로 세 개의 다른 파라미터 설정의 슈퍼 트렌드 지표로 구성되어 있습니다. 첫 번째 주요 슈퍼 트렌드 지표는 기본 트렌드 방향을 판단하는 데 기본 파라미터를 사용합니다. 두 번째 부 슈퍼 트렌드 지표는 ATR 주기를 낮추고 ATR 배수를 증가시켜 가격 변화를 더 민감하게 추적합니다. 세 번째 필터 슈퍼 트렌드 지표는 가짜 돌파구를 필터링하기 위해 ATR 주기와 ATR 배수를 적절하게 증가시킵니다.

메인 슈퍼 트렌드가 구매 신호를 발신할 때, 서브 슈퍼 트렌드가 동시에 신호를 발신할 때, 필터 슈퍼 트렌드가 상승하는 방향이라면, 전략은 추적 구매를 취합니다. 메인 슈퍼 트렌드가 판매 신호를 발신할 때, 서브 슈퍼 트렌드가 동시에 신호를 발신하고 필터 슈퍼 트렌드가 하락하는 방향이라면, 전략은 추적 판매를 취합니다.

전략적 이점

  1. 전략적 아이디어는 간단하고 명확하며, 이해하기 쉽고, 초보자에게 적합합니다.
  2. 정책 변수 설정이 합리적이어서 상황을 효과적으로 추적하고 위험을 제어할 수 있습니다.
  3. 전략적 신호는 정확하고 신뢰성이 높으며, 승률이 높다.
  4. 다양한 요소 조합을 결합하여 추적 효과를 달성합니다.
  5. 필터 메커니즘을 추가하여 잘못된 신호를 효과적으로 필터링하여 위험을 제어할 수 있습니다.

전략적 위험

  1. 주식 자체의 시스템적 위험
  2. 슈퍼 트렌드 지표가 일부 시장에서 지연될 수 있습니다.
  3. ATR 지표에 사용되는 변수 설정이 잘못되면 전략 신호가 오차가 발생할 수 있습니다.
  4. 전략적 거래량이 충분하지 않아 전체 지분 상쇄가 어려울 수 있습니다.

주요 위험 예방 조치:

  1. 유동성이 좋고 변동성이 높은 주식을 선택하세요
  2. 적절한 최적화 매개 변수, 지연의 가능성을 낮추기
  3. 매개 변수 테스트 최적화, 신호 정확도 향상
  4. 거래량을 적절히 늘려서 손해지기를 보장하세요.

전략 최적화 방향

  1. 다양한 ATR 주기 변수 조합을 테스트하여 추적 효과를 최적화합니다.
  2. 다른 변동성 지표로 ATR을 대체해보세요.
  3. 수퍼 트렌드 조합의 수를 늘리거나 줄이는 방법, 테스트 효과
  4. 다른 지표와 함께 신호 필터링을 최적화하십시오.
  5. 다른 손해 방지 방법을 시험해보고 최적의 방법을 찾습니다.

요약하다

이 전략의 전반적인 아이디어는 명확하고 간단하며, 다양한 파라미터 설정을 통해 여러 개의 슈퍼 트렌드 지표가 서로 협력하여 입점 추적 및 위험 통제를 구현한다. 전략 신호는 정확하고, 실판 성능이 좋으며, 초보자 학습에 적합하며, 또한 템플릿으로 다양한 지표 및 파라미터의 테스트 최적화를 수행 할 수 있습니다. 추천 할 만한 슈퍼 트렌드 전략이다.

전략 소스 코드
/*backtest
start: 2023-11-25 00:00:00
end: 2023-12-25 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Supertrend TEST 2 Strategy", overlay = true, format=format.price, precision=2)

Periods = input(title="ATR Period", type=input.integer, defval=4)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=4.7)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
tp=close
sl=close

atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green )
plotshape(buySignal and showsignals ? up : na, title="Лонг", text="Лонг", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white )
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red )
plotshape(sellSignal and showsignals ? dn : na, title="Шорт", text="Шорт", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white )
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white

sPeriods=input(title="ATR Period", type=input.integer, defval=8)
sMultiplier=input(title="dop ATR Multiplier", type=input.float, step=0.1, defval=1.5)
satr2 = sma(tr, sPeriods)
satr= changeATR ? atr(sPeriods) : satr2
ssup=ohlc4-(sMultiplier*satr)
ssup1 = nz(ssup[1],ssup)
ssup := close[1] > ssup1 ? max(ssup,ssup1) : ssup
sdn=ohlc4+(sMultiplier*satr)
sdn1 = nz(sdn[1], sdn)
sdn := close[1] < sdn1 ? min(sdn, sdn1) : sdn
strend = 1
strend := nz(strend[1], strend)
strend := strend == -1 and close > sdn1 ? 1 : strend == 1 and close < ssup1 ? -1 : strend
sbuySignal = strend == 1 and strend[1] == -1
ssellSignal = strend == -1 and strend[1] == 1

fPeriods=input(title="ATR Period", type=input.integer, defval=10)
fMultiplier=input(title="filter ATR Multiplier", type=input.float, step=0.1, defval=5)
fatr2 = sma(tr, fPeriods)
fatr= changeATR ? atr(fPeriods) : fatr2
fup=ohlc4-(fMultiplier*fatr)
fup1 = nz(fup[1],fup)
fup := close[1] > fup1 ? max(fup,fup1) : fup
fdn=ohlc4+(fMultiplier*fatr)
fdn1 = nz(fdn[1], fdn)
fdn := close[1] < fdn1 ? min(fdn, fdn1) : fdn
ftrend = 1
ftrend := nz(ftrend[1], ftrend)
ftrend := ftrend == -1 and close > fdn1 ? 1 : ftrend == 1 and close < fup1 ? -1 : ftrend
fbuySignal = ftrend == 1 and ftrend[1] == -1
fsellSignal = ftrend == -1 and ftrend[1] == 1
tcolor=color.new(color.gray,50)
fdnPlot = plot(ftrend == 1 ? na : fdn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=tcolor)
fupPlot = plot(ftrend == 1 ? fup : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=tcolor)



if (strategy.position_size > 0)
	tp:=tp[1]
	sl:=up
	strategy.exit("Long_TP/SL","Long",limit=tp, stop=sl)
	
if (strategy.position_size < 0)
	tp:=tp[1]
	sl:=dn
	strategy.exit("Short_TP/SL","Short",limit=tp, stop=sl)



if ((buySignal and  ftrend==1) or (sbuySignal and trend==1 and  ftrend==1)) 
	tp:=close+(close-up)*0.382
    strategy.entry("Long", strategy.long,  limit=tp, comment=tostring(round(tp)))
if ((sellSignal and ftrend==-1) or (ssellSignal and trend==-1 and  ftrend==-1)) 
	tp:=close-(dn-close)*0.382
    strategy.entry("Short", strategy.short, limit=tp, comment=tostring(round(tp)))