
이 전략은 카우프만 자기 적응 이동 평균 ((KAMA) 과 MACD를 기반으로 한 트렌드 추적 시스템이다. 그것은 KAMA를 주요 트렌드 판단 지표로 사용하여 MACD를 동력 확인 지표로 결합하여 시장의 트렌드를 지능적으로 추적하고 거래 시기를 정확하게 파악합니다. 이 전략은 4 시간 시간 프레임에서 작동하며, 동적 스톱 손실과 수익 목표를 사용하여 위험을 관리합니다.
전략의 핵심 논리는 다음과 같은 핵심 구성 요소를 기반으로 합니다.
이것은 고전 기술 지표 KAMA와 MACD의 혁신성을 결합한 트렌드 추적 전략이다. 적응형 이동 평균과 동력 확인의 조합과 완벽한 위험 관리 시스템으로 이 전략은 강력한 실용성과 안정성을 가지고 있다. 약간의 후진성과 변수 민감성의 위험이 있지만, 제안된 최적화 방향을 통해 전략의 안정성과 수익성을 더욱 향상시킬 수 있다.
/*backtest
start: 2024-02-20 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mckat
//@version=5
strategy("4-Hour KAMA Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === Inputs ===
ama_length = input.int(50, title="KAMA Length for 4H")
fast_length = input.int(3, title="KAMA Fast Length")
slow_length = input.int(30, title="KAMA Slow Length")
atr_length = input.int(14, title="ATR Length")
atr_mult = input.float(3.0, title="ATR Multiplier for Stop-Loss & Take-Profit")
// === KAMA Calculation ===
var float kama = na
price_change = math.abs(close - close[ama_length])
volatility_sum = 0.0
for i = 0 to ama_length - 1
volatility_sum := volatility_sum + math.abs(close[i] - close[i + 1])
efficiency_ratio = price_change / volatility_sum
smoothing_constant = math.pow(efficiency_ratio * (2 / (fast_length + 1) - 2 / (slow_length + 1)) + 2 / (slow_length + 1), 2)
kama := na(kama[1]) ? close : kama[1] + smoothing_constant * (close - kama[1])
// Plot KAMA
plot(kama, color=color.blue, title="KAMA (50)")
// === ATR for Stop-Loss and Take-Profit ===
atr = ta.atr(atr_length)
stop_loss = close - atr * atr_mult
take_profit = close + atr * atr_mult
// === MACD for Momentum Confirmation (Slow Settings for 4H) ===
[macd_line, signal_line, _] = ta.macd(close, 26, 52, 18)
macd_bullish = macd_line > signal_line
macd_bearish = macd_line < signal_line
// === Entry and Exit Conditions ===
buy_condition = ta.crossover(close, kama) and macd_bullish
sell_condition = ta.crossunder(close, kama) and macd_bearish
// === Execute Trades ===
if (buy_condition)
strategy.entry("Buy", strategy.long)
if (sell_condition)
strategy.close("Buy")
// === Dynamic Stop-Loss and Take-Profit ===
strategy.exit("Exit", "Buy", stop=stop_loss, limit=take_profit)
// === Plot Signals ===
plotshape(series=buy_condition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sell_condition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")