이중 이동 평균 세 배 기하급수 지표 거래 전략

저자:차오장, 날짜: 2023-12-15 15:39:45
태그:

img

전반적인 설명

이 전략은 두 개의 이동 평균 지표와 세 개의 기하급수 이동 평균 지표를 사용하여 스토카스틱 지표와 결합하여 상대적으로 안정적이고 신뢰할 수있는 트렌드 추적 거래 전략을 형성합니다. 주요 아이디어는 이동 평균 지표가 황금 십자가 또는 죽음의 십자가를 감지 할 때 거래 신호를 발급하는 것입니다. 스토카스틱 지표는 급격한 시장 변동 중에 잘못된 신호를 생성하지 않도록 과소매와 과소매 상황을 판단하는 데 도움이됩니다.

원칙

이 전략은 주로 네 가지 부분으로 구성됩니다.

  1. 이중 이동 평균 지표: 각각 50 기간 및 100 기간 기하급수 이동 평균 (EMA) 을 계산합니다. 단기 EMA가 장기 EMA를 넘을 때 구매 신호를 생성하고, 그 아래에 넘을 때 판매 신호를 생성합니다.

  2. 트리플 익스포넌셜 인디케이터 (Triple Exponential Indicator): 시장 트렌드 방향을 결정하기 위해 50주기, 100주기 및 200주기 지수 이동 평균을 계산합니다. 50EMA> 100EMA> 200EMA가 되면 상승 시장입니다. 50EMA<100EMA<200EMA가 되면 하락 시장입니다.

  3. 스토카스틱 인디케이터 (Stochastic Indicator): RSI의 6일 K 및 D 값을 계산하여 과잉 구매 및 과잉 판매 조건을 결정합니다. K 값이 D 값 위에 넘으면 과잉 판매됩니다. 아래로 넘으면 과잉 구매됩니다.

  4. 거래 신호: 두 개의 이동 평균 지표가 시장이 트리플 지수 이동 평균의 상승 또는 하락 상태에 따라 신호를 생성하고 스토카스틱 지표가 과반 구매 또는 과반 판매를 표시하지 않을 때만 진정한 거래 주문이 발행됩니다.

장점

이 전략은 이동 평균 지표와 스토카스틱 지표의 장점을 결합합니다. 거래 신호를 발행할 때 트렌드 방향 판단과 시장의 과잉 구매 / 과잉 판매 상태를 모두 고려하여 더 명확한 트렌드를 추적하기 위해 소음을 더 효과적으로 필터링합니다. 또한 세 배 지수 이동 평균을 사용하여 전체 추세를 결정하여 신호를 더 신뢰할 수 있습니다. 이 전략은 간단하고 구현하기 쉽고 최적화하기 쉽습니다.

위험 과 대책

이 전략의 가장 큰 위험은 지표 판단에 의존한다는 것입니다. 지표가 잘못된 신호를 내릴 때 쉽게 실패하는 거래로 이어질 수 있습니다. 또한 전체 추세를 결정하기 위해 더 긴 주기 이동 평균을 사용할 때 일부 단기 기회도 놓칠 수 있습니다. 주요 위험 대책은 다음과 같습니다.

  1. 지표 매개 변수를 최적화하고 두 개의 이동 평균과 세 개의 기하급수 이동 평균의 사이클 조합을 조정하여 시장 특성에 더 잘 맞출 수 있습니다.

  2. 시장이 급격한 변동이 나타나면 현재 거래를 종료하는 CANCEL 거래를 위한 더 많은 지표를 포함합니다.

  3. 장기적인 황소 시장에서 단기적 기회를 활용하기 위해 보조적인 단기적 상승 전략을 사용하십시오.

최적화 방향

이 전략을 최적화 할 수있는 주요 측면은 다음을 포함합니다.

  1. 두 개의 이동 평균과 세 개의 기하급수 이동 평균의 사이클 매개 변수를 조정하여 시장 특성에 대한 지표의 적응을 최적화하십시오.

  2. 부적절한 가격 움직임이 잘못된 신호를 유발하는 것을 피하기 위해 볼륨, MACD 및 기타 판단을 증가하십시오.

  3. 단기적 인 인기를 얻으면 잘못된 신호를 피하기 위해 촛불 패턴을 사용하여 트렌드를 확인하는 것이 좋습니다.

  4. 주식, 외환과 같은 더 많은 품종으로 확장하고 전략의 적응성을 테스트하십시오.

  5. 전체 시장 변동성을 결정하고 포지션 크기를 제어하기 위해 VIX 지표를 포함합니다.

결론

이 전략은 트레이딩 신호를 발행하기 위해 이중 이동 평균 지표를 사용하며, 트리플 지수 이동 평균과 스토카스틱 지표를 보완하여 비교적 안정적인 트렌드 추적 전략을 구축합니다. 간단하고 구현하기 쉽고 시장 특성에 잘 맞게 안정적인 수익을 창출합니다. 추천 할만한 양적 전략입니다. 타깃 최적화를 통해 더 나은 결과를 얻을 가능성이 있습니다.


/*backtest
start: 2023-12-07 00:00:00
end: 2023-12-12 08:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title='5212 EMA Strategy', shorttitle='5212 EMA', overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=10, calc_on_every_tick=false)

//**Backtest Date sof
useStartPeriodTime  = input.bool(true                       , 'Start Date & Time'   , group='Date Range'    , inline='Start Period')
startPeriodTime     = input(timestamp('16 Apr 2021')   , ''                    , group='Date Range'    , inline='Start Period')
useEndPeriodTime    = input.bool(false                      , 'End Date & Time'     , group='Date Range'    , inline='End Period')
endPeriodTime       = input(timestamp('31 Dec 2222')   , ''                    , group='Date Range'    , inline='End Period')
enableHighlight     = input.bool(false                      , 'Highlight'           , group='Date Range'    , inline='Highlight')
highlightType       = input.string('Anchors'                , ''                    , group='Date Range'    , inline='Highlight'    , options=['Anchors', 'Background'])
highlightColor      = input.color(color.white               , ''                    , group='Date Range'    , inline='Highlight')
start = useStartPeriodTime ? startPeriodTime >= time : false
end = useEndPeriodTime ? endPeriodTime <= time : false
calcPeriod = true
// var line startAnchor    = line.new(na, na, na, na, xloc.bar_time, extend.both, highlightColor, width=2)
// var line endAnchor      = line.new(na, na, na, na, xloc.bar_time, extend.both, highlightColor, width=2)
// useBgcolor = false
// if enableHighlight
//     if highlightType == 'Anchors'
//         if useStartPeriodTime
//             line.set_xy1(startAnchor, startPeriodTime, low)
//             line.set_xy2(startAnchor, startPeriodTime, high)
//         if useEndPeriodTime
//             line.set_xy1(endAnchor, calcPeriod ? time : line.get_x1(endAnchor), low)
//             line.set_xy2(endAnchor, calcPeriod ? time : line.get_x1(endAnchor), high)

//     if highlightType == 'Background'
//         useBgcolor := true
//         useBgcolor

// bgcolor(useBgcolor and calcPeriod ? color.new(highlightColor,90) : na, editable=false)
//**Backtest Date eof

src         =input(close    , 'Source'      , group='Support')
showEMA     = input(true    , 'Show EMA'    , group='Support')

//**Stochastic RSI sof
smoothK     = input.int(6   , "K"               , group='Stochastic RSI'    , minval=1)
smoothD     = input.int(6   , "D"               , group='Stochastic RSI'    , minval=1)
lengthRSI   = input.int(28  , "RSI Length"      , group='Stochastic RSI'    , minval=1)
lengthStoch = input.int(28  , "Stoch Length"    , group='Stochastic RSI'    , minval=1)

rsi1    = ta.rsi(src, lengthRSI)
k       = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d       = ta.sma(k, smoothD)
//**STochastic RSI eof

//** EMA sof
emain01     = input.int(50  , "EMAma Girang"    , group='Moving Average Exponential'    , minval=1)
emain02     = input.int(100 , "EMAma Muda"      , group='Moving Average Exponential'    , minval=1)
emain03     = input.int(200 , "EMAma Tua"       , group='Moving Average Exponential'    , minval=1)

ema01 = ta.ema(src, emain01)
ema02 = ta.ema(src, emain02)
ema03 = ta.ema(src, emain03)
plot(showEMA ? ema01 : na, 'EMAma Girang'   , color = color.new(color.orange, 0))
plot(showEMA ? ema02 : na, 'EMAma Muda'     , color = color.new(color.blue, 0))
plot(showEMA ? ema03 : na, 'EMAma Tua'      , color = color.new(color.red, 0))
//** EMA eof

//**Condition sof
emaLong     = ema01 > ema02 and ema02 > ema03 and low > ema03
emaShort    = ema01 < ema02 and ema02 < ema03 and high < ema03

longCond    = ta.crossover(k,d) and k <= 23 and emaLong
shortCond   = ta.crossunder(k,d) and k >= 77 and emaShort

longClose   = ta.crossunder(k,d) and k <= 77
shortClose  = ta.crossover(k,d) and k >= 23
longCross   = ta.crossover(ema01, ema02)
shortCross  = ta.crossunder(ema01, ema02)
//**Condition eof

//**Strategy sof
if calcPeriod and longCond
    strategy.entry('long', strategy.long, when=longCond, comment='EN Long')
strategy.close('long', when=shortClose, comment='EX Long')
strategy.close('long', when=shortCross, comment='MD Short')

if calcPeriod and shortCond
    strategy.entry('short', strategy.short, when=shortCond, comment='EN Short')
strategy.close('short', when=longClose, comment='EX Short')
strategy.close('short', when=longCross, comment='MD Long')

if calcPeriod == false and ta.crossover(ema01, ema02) or ta.crossunder(ema01, ema02)
    strategy.cancel('long')
    strategy.cancel('short')
//**Strategy eof

//**Label sof
entryText       = str.tostring(strategy.position_avg_price, '##.###')
longText    = 'Long Entry : ' + entryText 
shortText   = 'Short Entry : ' + entryText
noTrade     = 'Sleeping Mode'

LongTrade = strategy.position_size > 0
ShortTrade = strategy.position_size < 0

Tekslabel = LongTrade ? longText : ShortTrade ? shortText : noTrade

xPosition = timenow + math.round(ta.change(time)*1)
yPosition = ta.highest(1)
labelColor = LongTrade ? color.new(color.aqua, 0) : ShortTrade ? color.new(color.red, 0) : color.new(color.gray, 0)
textColor   = LongTrade ? color.new(color.black, 0) : ShortTrade ? color.new(color.white, 0) : color.new(color.white, 0)

// lab_l = label.new(
//           xPosition, yPosition, Tekslabel,
//           color=labelColor, 
//           textcolor=textColor, 
//           style =  label.style_label_left,
//           textalign=text.align_left,
//           xloc=xloc.bar_time, yloc = yloc.price)

// label.delete(lab_l[1])
//**Strategy eof


더 많은