
이 전략은 추적형의 슈퍼 트렌드 전략으로, 주요 아이디어는 다양한 파라미터 설정을 결합한 슈퍼 트렌드 지표를 사용하여 추적 효과를 달성하고 필터 지표를 사용하여 위험을 제어하는 것입니다. 전략의 핵심 아이디어는 간단하고 실용적이며, 이해하기 쉽고, 초보자 학습에 적합합니다.
이 전략은 주로 세 개의 다른 파라미터 설정의 슈퍼 트렌드 지표로 구성되어 있습니다. 첫 번째 주요 슈퍼 트렌드 지표는 기본 트렌드 방향을 판단하는 데 기본 파라미터를 사용합니다. 두 번째 부 슈퍼 트렌드 지표는 ATR 주기를 낮추고 ATR 배수를 증가시켜 가격 변화를 더 민감하게 추적합니다. 세 번째 필터 슈퍼 트렌드 지표는 가짜 돌파구를 필터링하기 위해 ATR 주기와 ATR 배수를 적절하게 증가시킵니다.
메인 슈퍼 트렌드가 구매 신호를 발신할 때, 서브 슈퍼 트렌드가 동시에 신호를 발신할 때, 필터 슈퍼 트렌드가 상승하는 방향이라면, 전략은 추적 구매를 취합니다. 메인 슈퍼 트렌드가 판매 신호를 발신할 때, 서브 슈퍼 트렌드가 동시에 신호를 발신하고 필터 슈퍼 트렌드가 하락하는 방향이라면, 전략은 추적 판매를 취합니다.
주요 위험 예방 조치:
이 전략의 전반적인 아이디어는 명확하고 간단하며, 다양한 파라미터 설정을 통해 여러 개의 슈퍼 트렌드 지표가 서로 협력하여 입점 추적 및 위험 통제를 구현한다. 전략 신호는 정확하고, 실판 성능이 좋으며, 초보자 학습에 적합하며, 또한 템플릿으로 다양한 지표 및 파라미터의 테스트 최적화를 수행 할 수 있습니다. 추천 할 만한 슈퍼 트렌드 전략이다.
/*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)))