
이는 시장에 나타나는 다기간 추세 선형 인글로핑 패턴을 식별하여 거래하는 인글로핑 패턴을 기반으로 한 양적 거래 전략입니다. 전략의 핵심은 가격 반전 신호를 포착하고, 보유 기간과 위험 관리를 결합해, 강력한 거래 결과를 얻는 것입니다. 이 전략은 모든 시장과 기간에 적용 가능하며 보편성이 강합니다.
이 전략은 촛대 패턴의 잉걸핑 패턴을 이용한 거래에 기초합니다. 상승형 삼키기 패턴이 발생하는 경우(작은 검은색 캔들스틱 다음에 큰 흰색 캔들스틱이 작은 검은색 캔들스틱을 완전히 삼키는 경우) 하락 추세에서 매수 신호가 생성됩니다. 하락형 삼키기 패턴이 발생하는 경우(작은 검은색 캔들스틱 다음에 큰 흰색 캔들스틱이 캔들스틱이 작은 검은색 캔들스틱을 완전히 삼키면(상승 추세에서 매수 신호가 생성됩니다. 매도 신호가 생성됩니다. 이 전략은 매개변수화를 통해 보유 기간을 설정하고, 과도한 보유로 인한 위험을 피하기 위해 지정된 기간이 지나면 자동으로 포지션을 청산합니다.
이 전략은 시장에서 포괄 패턴 기회를 포착하기 위한 체계적인 접근 방식을 사용하고 이를 매개변수화된 포지션 관리와 결합하여 위험 관리형 거래를 달성합니다. 이 전략은 매우 실용적이고 적응성이 뛰어나지만, 트레이더는 여전히 특정 시장 특성에 따라 전략을 최적화하고 조정해야 합니다. 전략의 안정성과 신뢰성을 개선하기 위해 다른 기술 지표와 위험 관리 조치를 결합하는 것이 좋습니다.
/*backtest
start: 2024-12-06 00:00:00
end: 2025-01-04 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("Engulfing Candlestick Strategy", overlay=true)
// Input parameters
bull_color = input.color(color.new(color.green, 0), title="Bullish Engulfing Highlight")
bear_color = input.color(color.new(color.red, 0), title="Bearish Engulfing Highlight")
hold_periods = input.int(17, title="Hold Periods", minval=1) // How many bars to hold the position
// Input for selecting the pattern (Bullish or Bearish Engulfing)
pattern_type = input.string("Bullish Engulfing", title="Engulfing Pattern", options=["Bullish Engulfing", "Bearish Engulfing"])
// Input for selecting the trade type (Long or Short)
trade_type = input.string("Long", title="Trade Type", options=["Long", "Short"])
// Conditions for Bullish Engulfing
bullish_engulfing = close > open and open < close[1] and close > open[1] and open[1] > close[1]
// Conditions for Bearish Engulfing
bearish_engulfing = close < open and open > close[1] and close < open[1] and open[1] < close[1]
// Declare the entry condition variable
var bool entry_condition = false // Set initial value to 'false'
// Entry logic based on selected pattern and trade type
if pattern_type == "Bullish Engulfing"
entry_condition := bullish_engulfing
else
entry_condition := bearish_engulfing
// Execute the entry based on the selected trade type
if entry_condition
if trade_type == "Long"
strategy.entry("Long", strategy.long)
else
strategy.entry("Short", strategy.short)
// Close position after specified number of bars
if strategy.position_size != 0 and bar_index - strategy.opentrades.entry_bar_index(0) >= hold_periods
strategy.close("Long")
strategy.close("Short")
// Highlight Bullish Engulfing Candles (Background Color)
bgcolor(bullish_engulfing and pattern_type == "Bullish Engulfing" ? color.new(bull_color, 80) : na, title="Bullish Engulfing Background")
// Highlight Bearish Engulfing Candles (Background Color)
bgcolor(bearish_engulfing and pattern_type == "Bearish Engulfing" ? color.new(bear_color, 80) : na, title="Bearish Engulfing Background")