모멘텀 이동 평균 통합 전략

저자:차오장, 날짜: 2024-01-25 11:39:00
태그:

img

전반적인 설명

이 전략은 주로 이동 평균선 HMA와 EMA에 의해 형성된 통합을 사용하여 구매 시기를 결정합니다. HMA가 EMA를 넘을 때 통합이 끝났다고 간주되며 새로운 상승 추세가 형성됩니다. 따라서 HMA가 동시에 EMA를 넘을 때 구매하십시오.

이 전략은 또한 RSI 지표를 결합하여 과반 구매 및 과반 판매 조건을 탐지합니다. RSI가 70보다 낮을 때 구입하고 RSI가 80보다 높을 때 부분 수익을 고려합니다.

전략 원칙

이 전략은 200주기 EMA와 HMA로 구성된 이동평균 시스템을 사용합니다. 그 중에서도 HMA 지표는 EMA를 기반으로 설계된 더 민감한 이동평균 지표입니다. HMA가 EMA를 넘을 때 통합 단계가 끝났고 주가가 상승하기 시작합니다. 이 시점에서 RSI 지표가 과잉 구매를 보여주지 않으면 구매 신호가 생성됩니다.

기존 포지션의 경우, 주식 가격이 다시 하락하고 HMA가 다시 EMA를 넘어서 새로운 통합의 시작을 나타낸다면 전체 포지션은 종료됩니다. 동시에, RSI가 80을 넘으면 손실을 방지하기 위해 이익의 20%가 부분적으로 취득됩니다.

이 전략의 거래 논리는 매우 간단하며, 주로 HMA와 EMA의 긴 및 짧은 교차에 의존하며, RSI의 최고와 최저로 결합하여 비교적 견고한 거래 전략을 형성합니다.

이점 분석

이 전략의 가장 큰 장점은 EMA와 HMA의 통합 거래 패턴을 활용함으로써 대부분의 가짜 브레이크를 필터링하여 수익률을 향상시킬 수 있다는 것입니다. 동시에 RSI 지표의 보조는 위험을 효과적으로 제어 할 수 있습니다. 둘의 조합은이 전략을 통합 및 변동성 시장에 매우 적합하게 만듭니다.

또한 이 전략은 3개의 지표만을 사용하며 논리가 간단하여 매개 변수를 최적화하고 백테스트를 쉽게 할 수 있으며 이는 전략의 검증과 개선에 도움이 됩니다.

위험 분석

이 전략은 몇 가지 장점을 가지고 있지만, 여전히 몇 가지 위험이 있습니다. 예를 들어, 보유 기간은 상대적으로 길어질 수 있으며, 지원하기 위해 충분한 자금이 필요합니다. 측면 통합 기간에 직면하면 손해를 멈추고 신속하게 빠져 나갈 수 없습니다. 이는 손해를 확장하는 상황에 쉽게 이어집니다.

또한, 이 전략은 주로 이동 평균 지표에 의존한다. 가격의 비정상적인 돌파구가 있을 경우, 스톱 로스 조치가 효력을 발휘할 수 없을 수 있어 더 큰 위험을 초래할 수 있다. 또한, 매개 변수 설정은 전략 성능에도 영향을 미치며 최적의 매개 변수를 찾기 위해 광범위한 테스트를 필요로 한다.

최적화 방향

위의 위험을 고려할 때, 이 전략은 다음과 같은 측면에서 최적화 될 수 있습니다.

  1. 변동성 지표를 결합하여 시장 변동성에 따라 포지션을 동적으로 조정합니다.

  2. 불필요한 반전 거래를 피하기 위해 트렌드 지표 판단을 늘려라.

  3. 이동 평균 매개 변수를 최적화하여 현재 시장 특성에 더 가깝게 만듭니다.

  4. 시간 정지기를 사용 하 여 너무 큰 단일 손실을 피 합니다.

요약

전체적으로, 이것은 비교적 고전적인 간단한 통합 및 변동성 전략입니다. 주식 지수 및 뜨거운 주식의 단기 및 중기 거래에 주로 사용되며 비교적 안정적인 알파 값을 얻을 수 있습니다. 매개 변수 최적화 및 위험 관리 조치를 강화함으로써이 전략의 성능은 여전히 개선 할 수있는 많은 여지가 있습니다.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mohanee

//@version=4
strategy(title="EMA_HMA_RSI_Strategy", overlay=true, pyramiding=2,     default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD)  //default_qty_value=10, default_qty_type=strategy.fixed, 

//longCondition = crossover(sma(close, 14), sma(close, 28))
//if (longCondition)
    //strategy.entry("My Long Entry Id", strategy.long)

//shortCondition = crossunder(sma(close, 14), sma(close, 28))
//if (shortCondition)
  //  strategy.entry("My Short Entry Id", strategy.short)

//HMA
HMA(src1, length1) =>  wma(2 * wma(src1, length1/2) - wma(src1, length1), round(sqrt(length1)))

var stopLossVal=0.00

//variables BEGIN
length=input(200,title="EMA and HMA Length")   //square root of 13

rsiLength=input(13, title="RSI Length")

takePartialProfits = input(true, title="Take Partial Profits (if this selected, RSI 13 higher reading over 80 is considered for partial closing ) ")

stopLoss = input(title="Stop Loss%", defval=8, minval=1)
//variables  END

//RSI 
rsi13=rsi(close,rsiLength)


ema200=ema(close,length)
hma200=HMA(close,length)

//exitOnAroonOscCrossingDown = input(true, title="Exit when Aroon Osc cross down zero ")


// Drawings

//Aroon oscillator

arronUpper = 100 * (highestbars(high, length+1) + length)/length
aroonLower = 100 * (lowestbars(low, length+1) + length)/length

aroonOsc  = arronUpper - aroonLower

aroonMidpoint = 0
//oscPlot = plot(aroonOsc, color=color.green)
//midLine= plot(aroonMidpoint, color=color.green)
//topLine = plot(90,style=plot.style_circles, color=color.green)
//bottomLine = plot(-90,style=plot.style_circles, color=color.red)

//fill(oscPlot, midLine, color=aroonOsc>0?color.green:color.red, transp=50)
//fill(topLine,bottomLine, color=color.blue)
//fill(topLine,oscPlot, color=aroonOsc>90?color.purple:na, transp=25)


// RSI 
//plot(rsi13, title="RSI", linewidth=2, color=color.purple)
//hline(50, title="Middle Line", linestyle=hline.style_dotted)
//obLevel = hline(80, title="Overbought", linestyle=hline.style_dotted)
//osLevel = hline(30, title="Oversold", linestyle=hline.style_dotted)
//fill(obLevel, osLevel, title="Background", color=rsi13 >=30 ? color.green:color.purple, transp=65)  // longTermRSI >=50

hullColor = hma200 > hma200[2] ? #00ff00 : #ff0000

plot(hma200, title="HULL 200", color=hullColor,  transp=25)
plot(ema200, title="EMA 200", color=color.orange)

//Entry--
strategy.initial_capital = 50000
strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, long=true,  when=strategy.position_size<1 and hma200 < ema200   and  hma200 > hma200[2]  and rsi13<70 )     //  // aroonOsc<0

//Add
if(strategy.position_size>=1 and  close < strategy.position_avg_price and  ( crossover(rsi13,30) or  crossover(rsi13,40) ) )   // hma200 < ema200   and  hma200 > hma200[2]   and hma200[2] < hma200[3] )  //and crossover(rsi13,30)  aroonOsc<0    //and hma200 > hma200[2]  and hma200[2] <= hma200[3]  //crossover(rsi13,30)
    qty1=(strategy.initial_capital * 0.10)/close
    //stopLossVal:= abs(strategy.position_size)>1 ?  ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 
    strategy.entry(id="Long Entry", comment="Add", qty=qty1, long=true )     //crossover(close,ema34)  //and close>ema34  //crossover(rsi5Val,rsiBuyLine)  --   SL="+tostring(stopLossVal, "####.##")


//stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-0.5) : 0.00 

stopLossVal:= abs(strategy.position_size)>1 ?  ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 
//stopLossVal:= abs(strategy.position_size)>1 ?  strategy.position_avg_price*(1-stopLoss*0.01) :  0.00

barcolor(color=strategy.position_size>=1? rsi13>80 ? color.purple: color.blue:na)

//close partial
if(takePartialProfits==true)
    strategy.close(id="Long Entry", comment="Partial X  points="+tostring(close - strategy.position_avg_price, "####.##"),  qty_percent=20 , when=abs(strategy.position_size)>=1 and crossunder(rsi13, 80)  and close > strategy.position_avg_price  )   //close<ema55 and rsi5Val<20 //ema34<ema55



//close All
//if(exitOnAroonOscCrossingDown)
  //  strategy.close(id="Long Entry", comment="Exit All points="+tostring(close - strategy.position_avg_price, "####.##"),  when=abs(strategy.position_size)>=1 and crossunder(aroonOsc, 0) )   //close<ema55 and rsi5Val<20 //ema34<ema55  //close<ema89

//close All on stop loss
strategy.close(id="Long Entry", comment="Stoploss X points="+tostring(close - strategy.position_avg_price, "####.##"),  when=abs(strategy.position_size)>=1 and close < stopLossVal  )  //close<ema55 and rsi5Val<20 //ema34<ema55  //close<ema89

strategy.close(id="Long Entry", comment="hmaXema X points="+tostring(close - strategy.position_avg_price, "####.##"),  when=abs(strategy.position_size)>=1 and close > strategy.position_avg_price  and  crossunder(hma200,ema200)  )  //close<ema55 and rsi5Val<20 //ema34<ema55  //close<ema89
    

더 많은