
이 전략은 알파 트렌드 지표와 카우프만 적응 이동 평균 (KAMA) 을 결합한 트렌드 추적 시스템이며, 위험 관리 기능을 통합합니다. 이 전략은 시장의 추세를 포착하는 동시에 부분적인 정지를 통해 위험을 관리하는 것입니다. 전략의 핵심은 알파 트렌드 지표를 사용하여 전체적인 트렌드 방향을 식별하는 데 있으며, KAMA는 더 정확한 입출력 신호를 생성하는 데 사용됩니다.
알파트렌드 지표 계산:
KAMA는 다음과 같이 계산했습니다.
거래 신호 생성:
위험 관리:
포지션 관리:
트렌드 적응력: 알파 트렌드와 KAMA를 결합하여 다양한 시장 환경에 더 잘 적응할 수 있습니다.
신호 신뢰성: 다중 조건 확인을 통해 거래 신호의 신뢰성을 높였다.
리스크 관리가 잘 되어있으며, 부분적인 제약 장치가 불안정한 시장에서 수익을 고정하는 데 도움이 됩니다.
유연한 포지션 관리: 계좌의 순가치에 기반한 포지션 관리 방식, 다양한 규모의 자금에 적합하다.
시각화 효과: 전략은 분석 및 모니터링을 위한 명확한 그래픽 인터페이스를 제공합니다.
가짜 돌파 위험: 불안한 시장에서 빈번한 가짜 돌파 신호가 발생할 수 있다.
지연성: 트렌드 추적 전략으로서, 트렌드 반전의 초기에는 느리게 반응할 수 있다.
매개 변수 민감성: 정책 성능은 매개 변수 설정에 민감할 수 있다.
회수 위험: 강세를 보이는 시장에서, 부분적인 하락은 큰 시장을 놓칠 수 있다.
시장 적응성: 특정 시장 조건에서 전략이 잘 작동하지 않을 수 있습니다.
동적 변수 조정:
다중 시간 프레임 분석:
이 글은 “미국어”를 가리킨다.
지성 손실:
시장 상태 분류:
알파 트렌드와 KAMA의 결합은 적응 트렌드 추적 및 위험 관리 전략이 포괄적이고 강력한 거래 시스템입니다. 그것은 알파 트렌드 지표와 KAMA의 장점을 결합하여 시장 추세를 정확하게 파악합니다. 전략의 위험 관리 메커니즘, 특히 부분적 제지 기능은 투자자에게 변동 시장에서 이익을 보호하는 효과적인 도구를 제공합니다.
/*backtest
start: 2024-06-01 00:00:00
end: 2024-06-30 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy('AlphaTrend with KAMA and Risk Management', shorttitle='AT+KAMA+RM', overlay=true, format=format.price, precision=2, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// AlphaTrend Inputs
coeff = input.float(1, 'AT Multiplier', step=0.1)
AP = input.int(14, 'AT Common Period', minval=1)
src = input.source(close, 'AT Source')
showsignals = input.bool(true, 'Show Signals?')
novolumedata = input.bool(false, 'Change calculation (no volume data)?')
// KAMA Inputs
kamaLength = input.int(21, 'KAMA Length', minval=1)
// Risk Management Inputs
profitTarget = input.float(10, 'Profit Target for Partial Exit (%)', minval=1, step=0.1)
// Yeni değişkenler
var float entryPrice = na
var string currentPosition = "flat" // "long", "short", veya "flat"
var float partialExitPrice = na
// AlphaTrend Calculation
ATR = ta.sma(ta.tr, AP)
upT = low - ATR * coeff
downT = high + ATR * coeff
AlphaTrend = 0.0
AlphaTrend := (novolumedata ? ta.rsi(src, AP) >= 50 : ta.mfi(hlc3, AP) >= 50) ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT
// KAMA Calculation
xPrice = close
xvnoise = math.abs(xPrice - xPrice[1])
nAMA = 0.0
nfastend = 0.666
nslowend = 0.0645
nsignal = math.abs(xPrice - xPrice[kamaLength])
// Manual calculation of sum
nnoise = 0.0
for i = 0 to kamaLength-1
nnoise := nnoise + xvnoise[i]
nefratio = nnoise != 0 ? nsignal / nnoise : 0
nsmooth = math.pow(nefratio * (nfastend - nslowend) + nslowend, 2)
nAMA := nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
// Plotting
color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B
k1 = plot(AlphaTrend, color=color.new(#0022FC, 0), linewidth=3, title='AlphaTrend')
k2 = plot(AlphaTrend[2], color=color.new(#FC0400, 0), linewidth=3)
fill(k1, k2, color=color1)
plot(nAMA, color=color.yellow, linewidth=2, title='KAMA')
// Sinyal koşulları
buyCondition = (ta.crossover(nAMA, AlphaTrend) and ta.crossover(nAMA, AlphaTrend[2])) or
(ta.crossover(nAMA, AlphaTrend) and nAMA > AlphaTrend[2]) or
(ta.crossover(nAMA, AlphaTrend[2]) and nAMA > AlphaTrend)
sellCondition = (ta.crossunder(nAMA, AlphaTrend) and ta.crossunder(nAMA, AlphaTrend[2])) or
(ta.crossunder(nAMA, AlphaTrend) and nAMA < AlphaTrend[2]) or
(ta.crossunder(nAMA, AlphaTrend[2]) and nAMA < AlphaTrend)
// Yeni Sinyaller
buySignal = buyCondition
sellSignal = sellCondition
// Alım satım mantığı
if (buySignal and currentPosition != "long")
if (currentPosition == "short")
strategy.close("Short")
strategy.entry("Long", strategy.long)
entryPrice := close
currentPosition := "long"
partialExitPrice := entryPrice * (1 + profitTarget / 100)
if (sellSignal and currentPosition != "short")
if (currentPosition == "long")
strategy.close("Long")
strategy.entry("Short", strategy.short)
entryPrice := close
currentPosition := "short"
partialExitPrice := entryPrice * (1 - profitTarget / 100)
// Kısmi çıkış mantığı
if (currentPosition == "long" and high >= partialExitPrice)
strategy.close("Long", comment="Partial Exit at " + str.tostring(profitTarget) + "% profit", qty_percent=50)
partialExitPrice := na
if (currentPosition == "short" and low <= partialExitPrice)
strategy.close("Short", comment="Partial Exit at " + str.tostring(profitTarget) + "% profit", qty_percent=50)
partialExitPrice := na
// Plotting signals
plotshape(buySignal and showsignals ? AlphaTrend * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 0))
plotshape(sellSignal and showsignals ? AlphaTrend * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0))
plotshape(currentPosition == "long" and high >= partialExitPrice ? high : na, title='PARTIAL EXIT LONG', text='PARTIAL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.orange, 0), textcolor=color.new(color.white, 0))
plotshape(currentPosition == "short" and low <= partialExitPrice ? low : na, title='PARTIAL EXIT SHORT', text='PARTIAL', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.orange, 0), textcolor=color.new(color.white, 0))
// Alerts
alertcondition(buySignal, title='BUY Signal', message='KAMA crossed above AlphaTrend - BUY!')
alertcondition(sellSignal, title='SELL Signal', message='KAMA crossed below AlphaTrend - SELL!')
alertcondition((currentPosition == "long" and high >= partialExitPrice) or (currentPosition == "short" and low <= partialExitPrice), title='Partial Exit', message='Profit target reached - Closing half position!')