슈퍼트렌드 전략 추적

저자:차오장, 날짜: 2023-12-26 15:58:55
태그:

img

전반적인 설명

이것은 트래킹 효과를 달성하기 위해 주로 다른 매개 변수 설정과 슈퍼 트렌드 지표를 결합하고 위험을 제어하기 위해 필터 지표를 사용하는 트래킹 슈퍼 트렌드 전략입니다. 전략의 핵심 아이디어는 간단하고 실용적이며 이해하기 쉽고 초보자도 배울 수 있습니다.

전략 원칙

이 전략은 주로 다른 매개 변수 설정을 가진 세 개의 슈퍼 트렌드 지표 그룹으로 구성됩니다. 첫 번째 그룹은 시장 트렌드의 기본 판단을 위해 기본 매개 변수를 사용하는 주요 슈퍼 트렌드 지표입니다. 두 번째 그룹은 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)))


더 많은