
이 전략은 슈퍼트렌드 지표를 기반으로 한 고급 추세 추종 거래 시스템으로, 여러 가지 신호 확인 메커니즘과 동적 포지션 관리를 결합한 것입니다. 전략의 핵심은 ATR(평균 진폭)을 통해 슈퍼트렌드선을 계산하고, 가격 추세와 보유 기간 창을 기반으로 거래 신호를 생성하여 시장 추세를 지능적으로 파악하는 것입니다.
이 전략은 3계층 신호 필터링 메커니즘을 사용합니다.
자본 관리 측면에서 이 전략은 계정 자본의 15%를 단일 거래량으로 사용합니다. 이러한 보수적인 포지션 제어는 위험 관리에 도움이 됩니다.
이는 완전한 구조와 엄격한 논리를 갖춘 추세 추적 전략입니다. 다중 신호 확인 메커니즘과 완전한 위험 관리 시스템을 통해 좋은 실용적 적용 가치가 있습니다. 이 전략은 확장성이 매우 뛰어나고, 추천되는 최적화 방향을 통해 안정성과 수익성을 더욱 개선할 수 있습니다.
/*backtest
start: 2024-12-06 00:00:00
end: 2025-01-04 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Supertrend Strategy", overlay=true)
atrPeriod = input(10, "ATR Length")
factor = input.float(3.0, "Factor", step=0.01)
// Compute supertrend values
[supertrendValue, supertrendDirection] = ta.supertrend(factor, atrPeriod)
var float direction = na
if not na(supertrendDirection[1]) and supertrendDirection[1] != supertrendDirection
direction := supertrendDirection > 0 ? 1 : -1
// Variables to track conditions
var int lastShortTime = na
var int lastLongTime = na
// Detecting short and long entries
if direction == -1
strategy.entry("My Short Entry Id", strategy.short)
lastShortTime := bar_index
if direction == 1
strategy.entry("My Long Entry Id", strategy.long)
lastLongTime := bar_index
// Custom signal logic
bool bullishSignal = false
bool bearishSignal = false
// Define bullish signal conditions
if not na(lastShortTime) and (bar_index - lastShortTime >= 15 and bar_index - lastShortTime <= 19)
if close > open and close[1] > open[1] and close[2] > open[2]
bullishSignal := true
// Define bearish signal conditions
if not na(lastLongTime) and (bar_index - lastLongTime >= 15 and bar_index - lastLongTime <= 19)
if close < open and close[1] < open[1] and close[2] < open[2]
bearishSignal := true
// Plot signals
if bullishSignal
strategy.entry("Bullish Upward Signal", strategy.long)
label.new(bar_index, close, text="Bullish", style=label.style_circle, color=color.green, textcolor=color.white)
if bearishSignal
strategy.entry("Bearish Downward Signal", strategy.short)
label.new(bar_index, close, text="Bearish", style=label.style_circle, color=color.red, textcolor=color.white)
// Optionally plot the strategy equity
//plot(strategy.equity, title="Equity", color=color.red, linewidth=2, style=plot.style_areabr)