이중 EMA 크로스오버 오스실레이션 추적 전략

저자:차오장, 날짜: 2024-01-03 11:38:51
태그:

img

전반적인 설명

듀얼 EMA 크로스오버 오시슬레이션 추적 전략은 EMA 지표를 사용하여 트렌드를 식별하고 변동적인 시장 조건에서 오시슬레이션을 추적하는 전략이다. 이 전략은 트렌드 추적 및 오시슬레이션 캡처의 개념을 모두 포함합니다. 강력한 트렌드 중 장기 추적과 오시슬레이션 중 단기 거래를 수행함으로써 더 나은 수익을 달성하는 것을 목표로합니다.

전략 논리

이 전략은 트렌드를 판단하기 위한 지표로 20주기 EMA를 사용합니다. 가격이 EMA를 넘으면 상승 추세를 나타내고, 가격이 그 아래를 넘으면 하락 추세를 나타냅니다.

가격이 EMA를 넘을 때, 지난 20개 기간 동안 가장 높은 가격으로 수익을 취하고, 크로스오버 이후 가장 낮은 낮은 가격으로 스톱 로스를 사용하여 긴 포지션을 입력합니다. 가격이 EMA를 넘을 때, 지난 20개 기간 동안 가장 낮은 가격으로 수익을 취하고, 크로스오버 이후 가장 높은 가격으로 스톱 로스를 사용하여 짧은 포지션을 입력합니다.

동시에, 전략은 ADX가 30보다 높는지 확인합니다. 트렌드가 충분히 강할 때, 즉 ADX가 30보다 높을 때만 거래를 수행합니다. 이것은 시장 변동 중에 정지되는 것을 피합니다.

오픈 트레이드 중에, 트레일링 스톱은 시장 조건에 따라 계속 조정되어 더 많은 이익을 얻을 수 있습니다.

이점 분석

이 전략은 트렌드 추적과 오스실레이션 거래의 장점을 결합합니다. 트렌딩 시장에서 더 높은 수익을 창출하고 오스실레이션 중에 더 일관된 수익을 창출 할 수 있습니다. 적응력이 강합니다.

EMA 사용은 또한 매개 변수를 단순하게 유지하여 과도한 최적화 위험을 줄이고 안정성을 보장합니다.

위험 분석

이 전략의 주요 위험은 강화 된 오스실레이션 중에 더 빈번한 스톱 아웃의 가능성이다. ADX가 등장하는 곳입니다. ADX가 낮을 때 거래를 비활성화함으로써 명확한 트렌드가 없으면 손실을 피할 수 있습니다.

또한 적절한 스톱 로스 배치도 중요합니다. 지나치게 넓은 스톱은 단일 거래 손실 금액을 증가시킬 수 있습니다. 지나치게 긴 스톱은 너무 민감하고 스톱 아웃 확률을 증가시킬 수 있습니다. 이익 목표와 스톱 로스 위험 사이의 균형을 찾아야 합니다.

최적화 방향

이 전략에 대한 가능한 최적화는 다음과 같습니다.

  1. 최적의 조합을 찾기 위해 더 많은 EMA 기간을 테스트합니다.

  2. ADX 기간 및 임계값을 포함한 ADX 매개 변수를 최적화합니다.

  3. 예를 들어 동적 스톱을 도입함으로써 수익 취득 및 스톱 손실 알고리즘을 개선합니다.

  4. KDJ와 MACD와 같은 추가 지표들을 결합하여 다중 지표 확인 시스템을 만들 것입니다.

요약

요약하자면, 이중 EMA 크로스오버 오스실레이션 추적 전략은 매우 실용적인 전략입니다. 트렌드 거래 전략과 오스실레이션 전략의 장점을 결합합니다. 장기 추적과 단기 거래 모두에 사용할 수 있습니다. 매개 변수 최적화 및 확인 지표를 추가함으로써 성능의 추가 개선이 가능합니다. 시장 조건에 대한 어느 정도의 분석 능력을 가진 투자자에게 적합합니다.


/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-02 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Linda Raschke's Holy Grail", shorttitle="RHG", default_qty_type = strategy.percent_of_equity, default_qty_value = 100, overlay = true)
adxlen = input(14, title="ADX period")
adxMin = input(30)
dilen = adxlen
f_highest(_src, _length)=>
    _adjusted_length = _length < 1 ? 1 : _length
    _value = _src
    for _i = 0 to (_adjusted_length-1)
        _value := _src[_i] >= _value ? _src[_i] : _value
    _return = _value

f_lowest(_src, _length)=>
    _adjusted_length = _length < 1 ? 1 : _length
    _value = _src
    for _i = 0 to (_adjusted_length-1)
        _value := _src[_i] <= _value ? _src[_i] : _value
    _return = _value

dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

emaLength = input(20)
curEma = ema(close, emaLength)
highPeriod = input(20)
d = na

takeProfitLong = highest(high, highPeriod) 
stopLossLong = f_lowest(low, barssince(low >= curEma))

if strategy.position_size == 0
    if adx(dilen, adxlen) <= adxMin or high < curEma 
        strategy.cancel("Long")
    if adx(dilen, adxlen) > adxMin and low < curEma and high > curEma and curEma > curEma[highPeriod / 2] and curEma > curEma[highPeriod] and takeProfitLong > high
        strategy.order("Long", strategy.long, stop = high)
        strategy.exit("Exit", "Long", limit = takeProfitLong, stop = stopLossLong)
        d := high

takeProfitShort = lowest(low, highPeriod) 
stopLossShort = f_highest(high, barssince(high <= curEma))

if strategy.position_size == 0
    if adx(dilen, adxlen) <= adxMin or low > curEma 
        strategy.cancel("Short")
    if adx(dilen, adxlen) > adxMin and high > curEma and low < curEma and curEma < curEma[highPeriod / 2] and curEma < curEma[highPeriod] and takeProfitShort < low
        strategy.order("Short", strategy.short, stop = low)
        strategy.exit("Exit", "Short", limit = takeProfitShort, stop = stopLossShort)
        d := low


strategy.close("Exit")

plot(d == high ? stopLossLong : d == low ? stopLossShort : na, style = circles, linewidth = 4, color = red)
plot(d == high ? takeProfitLong : d == low ? takeProfitShort : na, style = circles, linewidth = 4, color = green)
plot(d, style = circles, linewidth = 4, color = yellow)
plot(curEma, color = black, linewidth = 2)  

// === Backtesting Dates ===
testPeriodSwitch = input(false, "Custom Backtesting Dates")
testStartYear = input(2018, "Backtest Start Year")
testStartMonth = input(3, "Backtest Start Month")
testStartDay = input(6, "Backtest Start Day")
testStartHour = input(08, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
testStopYear = input(2018, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(14, "Backtest Stop Day")
testStopHour = input(14, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
isPeriod = testPeriodSwitch == true ? testPeriod() : true
// === /END
if not isPeriod
    strategy.cancel_all()
    strategy.close_all()


더 많은