
이 전략은 중심축 슈퍼 트렌드 지표와 이중 지수 이동 평균 ((DEMA) 지표를 결합하여 가격의 두 지표 사이의 위치 관계를 분석하여 거래 신호를 판단한다. 가격이 중심축 슈퍼 트렌드 지표를 뚫고 DEMA 지표보다 높을 때, 다중 신호를 생성하고, 가격이 중심축 슈퍼 트렌드 지표를 넘어 DEMA 지표보다 낮을 때, 공백 신호를 생성한다. 이 전략은 시장의 중장기 추세를 포착할 수 있으며, 또한 단기간에 가격 변동에 대응할 수 있다.
이 전략은 중심점 슈퍼 트렌드 지표와 DEMA 지표의 결합을 통해 시장 트렌드를 더 잘 포착 할 수 있으며, 단기 변동에도 대응 할 수 있습니다. 전략은 트렌드 추적 능력, 적응력, 위험 제어 능력 등의 장점을 가지고 있지만, 동시에 변수 설정, 시장의 흔들림 및 트렌드 전환과 같은 위험에 직면합니다. 변수 최적화, 신호 필터링, 포지션 관리 및 포트폴리오 최적화 등의 수단을 통해 전략의 안정성과 수익성을 더욱 향상시킬 수 있으며, 다양한 시장 환경에 더 잘 적응 할 수 있습니다.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Simple Combined Strategy: Pivot Point SuperTrend and DEMA", overlay=true)
// Pivot Point SuperTrend settings
prd = input.int(2, title="Pivot Point Period", minval=1, maxval=50)
Factor = input.float(3.0, title="ATR Factor", minval=1, step=0.1)
Pd = input.int(10, title="ATR Period", minval=1)
// Double EMA settings
demaLength = input.int(200, title="DEMA Length", minval=1)
src = input(close, title="Source")
// Pip settings
pipValue = input.float(0.0001, title="Pip Value")
stopLossPips = input.int(15, title="Stop Loss (pips)")
takeProfitPips = input.int(35, title="Take Profit (pips)")
// Pivot Point SuperTrend Calculation
float ph = ta.pivothigh(prd, prd)
float pl = ta.pivotlow(prd, prd)
var float center = na
if not na(ph)
center := na(center) ? ph : (center * 2 + ph) / 3
if not na(pl)
center := na(center) ? pl : (center * 2 + pl) / 3
Up = center - (Factor * ta.atr(Pd))
Dn = center + (Factor * ta.atr(Pd))
var float TUp = na
var float TDown = na
var int Trend = na
if na(Trend)
TUp := Up
TDown := Dn
Trend := close > Dn ? 1 : -1
else
TUp := close[1] > TUp[1] ? math.max(Up, TUp[1]) : Up
TDown := close[1] < TDown[1] ? math.min(Dn, TDown[1]) : Dn
Trend := close > TDown[1] ? 1 : close < TUp[1] ? -1 : nz(Trend[1], 1)
Trailingsl = Trend == 1 ? TUp : TDown
linecolor = Trend == 1 ? color.lime : color.red
plot(Trailingsl, color=linecolor, linewidth=2, title="PP SuperTrend")
// Double EMA Calculation
e1 = ta.ema(src, demaLength)
e2 = ta.ema(e1, demaLength)
dema = 2 * e1 - e2
plot(dema, "DEMA", color=color.new(#43A047, 0))
// Strategy Logic
longCondition = close > Trailingsl and close > dema and strategy.position_size <= 0
shortCondition = close < Trailingsl and close < dema and strategy.position_size >= 0
// Plot signals
plotshape(series=longCondition, title="Long", location=location.belowbar, color=color.green, style=shape.labelup, text="Long")
plotshape(series=shortCondition, title="Short", location=location.abovebar, color=color.red, style=shape.labeldown, text="Short")
// Strategy Entry and Exit
if (longCondition)
strategy.entry("Long", strategy.long, stop=close - (stopLossPips * pipValue), limit=close + (takeProfitPips * pipValue))
if (shortCondition)
strategy.entry("Short", strategy.short, stop=close + (stopLossPips * pipValue), limit=close - (takeProfitPips * pipValue))
alertcondition(longCondition, title="Long Alert", message="Long Signal")
alertcondition(shortCondition, title="Short Alert", message="Short Signal")