전략에 따른 배조 이동 평균 트렌드

저자:차오장, 날짜: 2023-09-16 18:41:33
태그:

전반적인 설명

헐 이동 평균 트렌드 다음 전략은 시장 트렌드 방향을 결정하고 구매 및 판매 신호를 생성하기 위해 헐 이동 평균을 사용합니다. 중장기 트렌드를 캡처하고, 트렌드 시작 초기 포지션을 설정하고, 트렌드 반전 전에 포지션을 닫습니다.

원칙

이 전략은 트렌드 방향을 결정하기 위해 홀 이동 평균과 간단한 이동 평균을 모두 사용합니다. 짧은 기간 홀 MA가 더 긴 기간 홀 MA를 넘을 때 구매 신호를 생성합니다. 짧은 기간 홀 MA가 더 긴 기간 이하로 넘을 때 판매 신호를 생성합니다.

간단한 이동 평균은 실시간 트렌드 방향을 결정한다. 짧은 EMA가 긴 EMA를 넘을 때 상승 추세를 나타낸다. 짧은 EMA가 긴 EMA를 넘을 때 하락 추세를 나타낸다. 홀 MA와 EMA 신호가 상승 또는 하락 편향에 동의할 때만 거래를 한다.

또한, 전략은 시장 변동을 측정하고 통합 거래를 피하기 위해 K-라인 몸 채널을 사용합니다. 거래는 가격이 채널 범위를 벗어날 때만 고려됩니다.

장점

  • 헐 MA는 가격 변화와 초기 트렌드 전환을 감지하는 데 더 민감합니다.

  • Hull MA와 EMA를 모두 사용하면 잘못된 신호가 없지 않습니다.

  • K-라인 채널은 옆 시장에서 과도한 거래를 피합니다.

  • 트렌드를 따라가는 것은 트렌드가 확장됨에 따라 지속적인 수익을 얻을 수 있습니다.

위험성

  • 이동 평균은 지연이 있고 최적의 트렌드 반전 입구 지점을 놓칠 수 있습니다.

  • 정확하지 않은 통합 검출은 나쁜 거래를 유발할 수 있습니다.

  • 거래 빈도가 낮으면 단 한번의 손실이 큰 영향을 줍니다.

  • 단기적인 변동을 활용할 수 없습니다.

위험 관리

  • 적절한 트렌드 신호를 생성하기 위해 MA 기간을 최적화합니다.

  • 통합을 결정하기 위해 RSI와 BBANDS 같은 다른 지표를 사용하십시오.

  • 공격적인 자본 관리를 실시하여 거래당 손실 비율을 제한합니다.

  • 단기 수익을 창출하기 위한 다른 전략과 보완합니다.

요약

헐 이동 평균 트렌드를 따르는 전략은 헐 MA와 EMA의 결합 사용을 통해 중장기 트렌드를 효과적으로 추적합니다. 이윤 트렌드 전반에 걸쳐 이익을 축적하고 반전 전에 일찍 빠져 나갑니다. 이것은 간단하고 실용적인 양 거래 전략입니다. 추천 할 가치가 있습니다.


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

//@version=2

// strategy(title='HULLMiguel 2019/ Strategy v3', shorttitle='HULLMiguel_2019_Strategy', overlay=true, pyramiding=0, default_qty_value=1000, initial_capital=1000, currency=currency.USD)

//Candle body resistance Channel-----------------------------//
len = 34
src = input(close, title="Candle body resistance Channel")
out = sma(src, len)
last8h = highest(close, 13)
lastl8 = lowest(close, 13)
bearish = cross(close,out) == 1 and falling(close, 1)
bullish = cross(close,out) == 1 and rising(close, 1)
channel2=input(false, title="Bar Channel On/Off")
ul2=plot(channel2?last8h:last8h==nz(last8h[1])?last8h:na, color=black, linewidth=1, style=linebr, title="Candle body resistance level top", offset=0)
ll2=plot(channel2?lastl8:lastl8==nz(lastl8[1])?lastl8:na, color=blue, linewidth=1, style=linebr, title="Candle body resistance level bottom", offset=0)
//fill(ul2, ll2, color=black, transp=95, title="Candle body resistance Channel")

//-----------------Support and Resistance 
RST = input(title='Support / Resistance length:',  defval=15) 
RSTT = valuewhen(high >= highest(high, RST), high, 0)
RSTB = valuewhen(low <= lowest(low, RST), low, 0)
RT2 = plot(RSTT, color=RSTT != RSTT[1] ? na : red, linewidth=1, offset=+0)
RB2 = plot(RSTB, color=RSTB != RSTB[1] ? na : green, linewidth=1, offset=0)

//--------------------Trend colour ema------------------------------------------------// 
src0 = close, len0 = input(13, minval=1, title="EMA 1")
ema0 = ema(src0, len0)
direction = rising(ema0, 2) ? +1 : falling(ema0, 2) ? -1 : 0
plot_color = direction > 0  ? lime: direction < 0 ? red : na
plot(ema0, title="EMA", style=line, linewidth=3, color = plot_color)

//-------------------- ema 2------------------------------------------------//
src02 = close, len02 = input(21, minval=1, title="EMA 2")
ema02 = ema(src02, len02)
direction2 = rising(ema02, 2) ? +1 : falling(ema02, 2) ? -1 : 0
plot_color2 = direction2 > 0  ? green: direction2 < 0 ? red : na
plot(ema02, title="EMA Signal 2", style=line, linewidth=2, color = plot_color2)

//=============Hull MA//
show_hma = input(false, title="Display Hull MA Set:")
hma_src = input(close, title="Hull MA's Source:")
hma_base_length = input(16, minval=1, title="Hull MA's Base Length:")
hma_length_scalar = input(10, minval=0, title="Hull MA's Length Scalar:")
hullma(src, length)=>wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length)))
plot(not show_hma ? na : hullma(hma_src, hma_base_length+hma_length_scalar*6), color=black, linewidth=5, title="Hull MA")
dif_close_hull= (close-hullma(hma_src, hma_base_length+hma_length_scalar*6))/close
Percent_dif = (dif_close_hull/(hullma(hma_src, hma_base_length+hma_length_scalar*6)))
//direction3 = Percent_dif>0 ? +1 : Percent_dif<0 ? -1 : 0
//plot_color3 = direction3 > 0  ? lime: direction3 < 0 ? red : na
//plot(dif_close_hull, title="dif close hull", style=line, linewidth=6, color = plot_color3)

//============ signal Generator ==================================//
Piriod=input('720')
ch1 = security(syminfo.tickerid, Piriod, open)
ch2 = security(syminfo.tickerid, Piriod, close)
plot(ch1, title="EMA Signal 2", style=line, linewidth=1, color = blue)
//longCondition = crossover(security(tickerid, Piriod, close),security(tickerid, Piriod, open))
//plot((close-ema02)/ema02+close)
longCondition = direction > 0 and direction2> 0

if (longCondition)
    strategy.entry("BUY", strategy.long)
//shortCondition = crossunder(security(tickerid, Piriod, close),security(tickerid, Piriod, open))
shortCondition = direction < 0 and direction2 < 0

if (shortCondition)
    strategy.entry("SELL", strategy.short)

///////////////////////////////////////////////////////////////////////////////////////////

더 많은