
이 글은 다바스 상자 ((Darvas Box) 와 25주기 이동 평균 ((MA25) 을 결합한 트렌드 추적 거래 시스템이다. 이 전략은 가격 평평한 범위를 형성하는 상자를 식별하고, 평평한 트렌드 확인과 결합하여, 돌파할 때 강력한 상황을 포착한다. 시스템 설계는 트렌드 지속성과 가짜 돌파구를 충분히 고려하여, 거래자에게 완전한 시장 진출 장을 제공합니다.
이 전략은 크게 세 가지 핵심 요소로 구성되어 있습니다.
이 전략은 고전적인 다바스 박스체 이론과 이동 평균 트렌드 추적을 결합하여 안정적인 거래 시스템을 구축한다. 시스템의 주요 장점은 트렌드적인 행동을 효과적으로 포착할 수 있고, 동시에 여러 필터링 메커니즘을 통해 위험을 제어하는 것이다. 약간의 낙후성이 있음에도 불구하고, 합리적인 매개 변수 최적화 및 위험 관리를 통해 이 전략은 트렌드 시장에서 안정적인 성능을 얻을 수 있다.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("DARVAS BOX with MA25 Buy Condition", overlay=true, shorttitle="AEG DARVAS")
// Input for box length
boxp = input.int(5, "BOX LENGTH")
// Calculate 25-period moving average
ma25 = ta.sma(close, 25)
// Lowest low and highest high within the box period
LL = ta.lowest(low, boxp)
k1 = ta.highest(high, boxp)
k2 = ta.highest(high, boxp - 1)
k3 = ta.highest(high, boxp - 2)
// New high detection
NH = ta.valuewhen(high > k1[1], high, 0)
// Logic to detect top and bottom of Darvas Box
box1 = k3 < k2
TopBox = ta.valuewhen(ta.barssince(high > k1[1]) == boxp - 2 and box1, NH, 0)
BottomBox = ta.valuewhen(ta.barssince(high > k1[1]) == boxp - 2 and box1, LL, 0)
// Plot the top and bottom Darvas Box lines
plot(TopBox, linewidth=3, color=color.green, title="Top Box")
plot(BottomBox, linewidth=3, color=color.red, title="Bottom Box")
plot(ma25, color=#2195f31e, linewidth=2, title="ma25")
// --- Buy and Sell conditions ---
// Buy when price breaks above the Darvas Box AND MA15
buyCondition = ta.crossover(close, TopBox) and close > ma25
// Sell when price drops below the Darvas Box
sellCondition = ta.crossunder(close, BottomBox)
// --- Buy and Sell Signals ---
// Plot BUY+ and SELL labels
plotshape(series=buyCondition, title="Buy+ Signal", location=location.abovebar, color=#72d174d3, style=shape.labeldown, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.belowbar, color=color.rgb(234, 62, 62, 28), style=shape.labelup, text="SELL")
// --- Strategy execution ---
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.close("Buy")