삼배 기하급수적 이동 평균 이익 취득 및 중지 손실 전략

저자:차오장, 날짜: 2024-02-04 10:38:42
태그:

img

전반적인 설명

트리플 기하급수적 이동 평균 이익 취득 및 손실 중지 전략은 시장 진입 및 출구에 대한 다른 기간을 가진 세 가지 기하급수적 이동 평균을 기반으로하는 트렌드 추종 전략입니다. 또한 위험 관리에 대한 이익 취득 및 손실 중지 수준을 설정하기 위해 평균 진정한 범위 지표를 사용합니다.

전략 논리

이 전략은 세 가지 기하급수적인 이동 평균을 사용합니다. 빠른 라인, 중간 라인, 느린 라인. 중간 라인이 느린 라인의 위를 넘을 때 길게 이동하고 빠른 라인이 중간 라인의 아래를 넘을 때 포지션을 닫습니다. 이것은 세 가지 이동 평균의 교차를 통해 트렌드 방향성을 결정하는 전형적인 트렌드를 따르는 전략입니다.

동시에, 전략은 평균 참 범위 지표를 활용하여 수익 취득 및 스톱-러스 수준을 계산합니다. 구체적으로, 긴 포지션의 이익 취득은 엔트리 가격 + 평균 참 범위 * 수익 인수이며, 짧은 포지션의 경우 엔트리 가격 - 평균 참 범위 * 수익 인수입니다. 스톱 손실 논리는 비슷합니다. 이것은 큰 손실의 위험을 효과적으로 제한합니다.

이점 분석

  1. 결정 지표는 직관적이고 이해하기 쉽습니다.
  2. 체계적이고 자동화하기 쉽습니다.
  3. 트렌드 따라와 위험 통제를 균형 잡습니다.

위험 분석

  1. 약간의 지연과 역행을 적시에 포착할 수 없다는 것입니다.
  2. 다양한 시장에서 손실을 멈추는 경향이 있습니다.
  3. 파라미터 튜닝은 최적화가 필요해 그렇지 않으면 결과가 좋지 않을 수 있습니다.

위험 완화 조치는: 이동 평균 기간을 단축하고, 수익/정지 요인을 최적화하고, 보조 지표를 추가합니다.

최적화 방향

  1. 최적의 매개 변수를 찾기 위해 이동 평균의 조합을 테스트합니다.
  2. MACD, RSI 등과 같은 다른 기술 지표를 추가합니다.
  3. 기계 학습을 사용하여 자동으로 매개 변수를 최적화합니다.
  4. 실제 범위에 따라 수익/정지 수준을 동적으로 조정합니다.
  5. 너무 많은 사람들을 피하기 위해 감정을 포함하십시오.

결론

전체적으로 이것은 안정적인 성능과 간단한 매개 변수를 통해 쉽게 구현되는 효과적인 트렌드를 따르는 전략이다. 평균 진정한 범위에 기반한 동적 이익 취득 및 스톱 손실은 측면 리스크를 제한한다. 그러나 매개 변수 최적화 및 지표 조합은 과잉 조정 또는 의사 결정 지연을 방지하기 위해 신중하게 수행되어야 한다. 균형으로, 이 전략은 좋은 위험 보상 프로파일을 가지고 있으며 고려할 가치가 있다.


/*backtest
start: 2024-01-04 00:00:00
end: 2024-02-03 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//© Densz
strategy("3EMA with TP & SL (ATR)", overlay=true )

// INPUTS
startTime           =       input(title="Start Time", type = input.time, defval = timestamp("01 Jan 2017 00:00 +0000"))
endTime             =       input(title="End Time", type = input.time, defval = timestamp("01 Jan 2022 00:00 +0000"))

slowEMALength       =       input(title="Slow EMA Length", type = input.integer, defval = 55)
middleEMALength     =       input(title="Middle EMA Length", type = input.integer, defval = 21)
fastEMALength       =       input(title="Fast EMA Length", type = input.integer, defval = 9)

trendMALength       =       input(title="Trend indicator MA Length", type = input.integer, defval = 200)

atrLength           =       input(title="ATR Length", type = input.integer, defval = 14)
tpATRMult           =       input(title="Take profit ATR multiplier", type = input.integer, defval = 3)
slATRMult           =       input(title="Stop loss ATR multiplier", type = input.integer, defval = 2)

rsiLength           =       input(title="RSI Length", type = input.integer, defval = 14)

// Indicators
slowEMA             =       ema(close, slowEMALength)
middEMA             =       ema(close, middleEMALength)
fastEMA             =       ema(close, fastEMALength)
atr                 =       atr(atrLength)

rsiValue            =       rsi(close, rsiLength)
isRsiOB             =       rsiValue >= 80
isRsiOS             =       rsiValue <= 20

sma200              =       sma(close, trendMALength)

inDateRange         =       true

// Plotting
plot(slowEMA, title="Slow EMA", color=color.red, linewidth=2, transp=50)
plot(middEMA, title="Middle EMA", color=color.orange, linewidth=2, transp=50)
plot(fastEMA, title="Fast EMA", color=color.green, linewidth=2, transp=50)

plot(sma200, title="SMA Trend indicator", color=color.purple, linewidth=3, transp=10)
plotshape(isRsiOB, title="Overbought", location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, text="OB")
plotshape(isRsiOS, title="Oversold", location=location.belowbar, color=color.green, transp=0, style=shape.triangledown, text="OS")

float takeprofit    =       na
float stoploss      =       na

var line tpline     =       na
var line slline     =       na

if strategy.position_size != 0
    takeprofit := takeprofit[1]
    stoploss := stoploss[1]
    line.set_x2(tpline, bar_index)
    line.set_x2(slline, bar_index)
    line.set_extend(tpline, extend.none)
    line.set_extend(slline, extend.none)
    
// STRATEGY
goLong  = crossover(middEMA, slowEMA) and inDateRange
closeLong = crossunder(fastEMA, middEMA) and inDateRange


if goLong
    takeprofit := close + atr * tpATRMult
    stoploss := close - atr * slATRMult
    // tpline := line.new(bar_index, takeprofit, bar_index, takeprofit, color=color.green, width=2, extend=extend.right, style=line.style_dotted)
    // slline := line.new(bar_index, stoploss, bar_index, stoploss, color=color.red, width=2, extend=extend.right, style=line.style_dotted)
    // label.new(bar_index, takeprofit, "TP", style=label.style_labeldown)
    // label.new(bar_index, stoploss, "SL", style=label.style_labelup)
    strategy.entry("Long", strategy.long, when = goLong)
    strategy.exit("TP/SL", "Long", stop=stoploss, limit=takeprofit)
if closeLong
    takeprofit := na
    stoploss := na
    strategy.close(id = "Long", when = closeLong)

if (not inDateRange)
    strategy.close_all()


더 많은