
이 전략은 평균 실제 파도 (Average True Range, ATR) 지표를 기반으로 초 트렌드 (SuperTrend) 채널을 구축하고, 가격의 초 트렌드 채널을 뚫고 구매 및 판매 신호를 생성한다. 이 전략은 트렌드 추적과 스톱 관리의 장점을 결합하여 트렌드 방향을 효과적으로 추적 할 수 있다.
슈퍼 트렌드 채널의 상단 궤도와 하단 궤도는 다음과 같은 공식으로 계산된다:
오프 레일 = (최고 가격 + 최저 가격) / 2 + ATR (n) * 인수 하도 = (최고 가격 + 최소 가격) / 2 - ATR (n) * 인자
그 중, ATR(n) 은 n 일 동안의 평균 실제 진폭을 나타내며, 인자는 조정 가능한 변수이며, 기본적으로 3。이다.
종결 가격이 상반기보다 높을 때 보이스 신호, 종결 가격이 하반기보다 낮을 때 보이스 신호. 전략은 보이스 신호와 보이스 신호에 따라 입시와 출시를 결정한다.
위험 해결 방법:
이 전략은 초 트렌드 채널을 사용하여 트렌드 추적 및 손실 관리를 구현한다. ATR 주기 및 인자 파라미터의 매칭은 전략 효과에 매우 중요합니다. 다음 단계는 파라미터 최적화, 신호 필터링 등의 측면에서 전략을 더욱 최적화하여 더 복잡한 시장 환경에 적응할 수 있도록 할 것이다.
/*backtest
start: 2023-01-11 00:00:00
end: 2024-01-17 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Supertrend Backtest", shorttitle="STBT", overlay=true)
// Input for ATR Length
atrLength = input.int(10, title="ATR Length", minval=1)
atrFactor = input.float(3.0, title="Factor", minval=0.01, step=0.01)
// Calculate SuperTrend
[supertrend, direction] = ta.supertrend(atrFactor, atrLength)
supertrend := barstate.isfirst ? na : supertrend
// Define entry and exit conditions
longCondition = ta.crossover(close, supertrend)
shortCondition = ta.crossunder(close, supertrend)
// Plot the SuperTrend
plot(supertrend, color=color.new(color.blue, 0), title="SuperTrend")
// Plot Buy and Sell signals
plotshape(series=longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(series=shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")
// Strategy Entry and Exit
strategy.entry("Long", strategy.long, when=longCondition)
strategy.entry("Short", strategy.short, when=shortCondition)