STEM과 MATCS가 결합된 모멘텀 트레이딩 전략


생성 날짜: 2023-09-15 16:22:48 마지막으로 수정됨: 2023-09-15 16:22:48
복사: 0 클릭수: 655
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략은 STEM와 MATCS 포트폴리오 동력 거래 전략이라 불린다. 이 전략은 Supertrend 지표와 MACD 지표의 조합을 사용하여 거래 신호를 형성한다.

전략의 작동 원리:

  1. 수퍼트렌드 지표의 계산은 가격 변동에 따라 구매 및 판매 신호를 생성한다.
  2. MACD 지표의 패스트라인, 중선 및 슬로우라인 계산하라. 패스트라인 상에서 중선을 통과할 때 구매 신호가 발생하고 패스트라인 아래에서 중선을 통과할 때 판매 신호가 발생한다.
  3. 슈퍼트렌드와 MACD 지표가 결합되면, 둘 다 동시에 신호를 내면만 진입할 수 있다.
  4. ATR 지수를 사용하여 동적 스톱로스를 계산한다.

특정 거래 규칙:

  1. 수퍼트렌드 전환이 하락으로 전환되고 MACD 빠른 라인에서 중선을 통과하면 더 많은 입장을 니다.
  2. 수퍼트렌드 전환이 을 뒤집고 MACD 패스트 라인이 중간 라인을 통과 할 때, 공백 입찰
  3. 평위 조건: 중지 손실 또는 중지 (선택가능)

이 전략의 장점:

  1. 여러 지표를 조합하여 신호의 정확도를 향상시킵니다.
  2. 동적 손실은 개인 손실을 제한할 수 있습니다.
  3. 트렌드 추적 및 반전 거래 능력

이 전략의 위험은:

  1. 수퍼트렌드 및 MACD 지표의 파라미터가 잘못 설정되어 잘못된 신호가 발생할 수 있습니다.
  2. 스톱포인트가 너무 가까워서 자주 스톱포인트가 될 수 있다.
  3. 거래 비용과 슬라이드 포인트가 수익에 영향을 미칩니다.

종합적으로 STEM와 MATCS 포트폴리오 동력 전략은 지표 통합을 통해 증진 효과를 발휘하며, 단선과 중선 거래에 적합하다. 스톱로스 전략의 적용은 위험을 제어하는 데 매우 중요합니다. 거래자는 매개 변수 최적화와 엄격한 자금 관리를 통해 실물 거래의 위험을 줄여야 한다.

전략 소스 코드
/*backtest
start: 2023-09-07 00:00:00
end: 2023-09-14 00:00:00
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/
// © IncomePipelineGenerator
//@version=4
// strategy("STRAT_STEM_MATCS_BTC", overlay=true, pyramiding = 0, default_qty_value = 20, slippage = 5)


ST_EMA_PERIOD = input(1, minval=1)
ST_EMA = ema(close, ST_EMA_PERIOD)

LENGTH = input(title="ATR_PERIOD", type=input.integer, defval=95)
ATR_TUNE = input(title="ATR_TUNE", type=input.float, step=0.1, defval=2.1)
showLabels = input(title="Show_Buy/Sell_Labels ?", type=input.bool, defval=true)
highlightState = input(title="Highlight_State ?", type=input.bool, defval=true)

ATR = ATR_TUNE * atr(LENGTH)

longStop = ST_EMA - ATR
longStopPrev = nz(longStop[1], longStop)
longStop := (close[1]) > longStopPrev ? max(longStop, longStopPrev) : longStop

shortStop = ST_EMA + ATR
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := (close[1]) < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop

dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and (close) > shortStopPrev ? 1 : dir == 1 and (close) < longStopPrev ? -1 : dir


fastLength = input(3, minval=1), medLength=input(9, minval=1), slowLength=input(12, minval=1), signalLength=input(16,minval=1)
fastMA = ema(close, fastLength), medMA = ema(close, medLength), slowMA = ema(close, slowLength)

macd = fastMA - slowMA
fmacd = fastMA - medMA
smacd = slowMA - medMA

signal = ema(macd, signalLength)
fsignal = ema(fmacd, signalLength)
ssignal = ema(smacd, signalLength)


SetStopLossShort = 0.0
SetStopLossShort := if(strategy.position_size < 0)
    StopLossShort = shortStop
    min(StopLossShort,SetStopLossShort[1])

SetStopLossLong = 0.0
SetStopLossLong := if(strategy.position_size > 0)
    StopLossLong = longStop
    max(StopLossLong,SetStopLossLong[1])


ATR_CrossOver_Period = input(5, type=input.integer, minval=1, maxval=2000)
ATR_SIGNAL_FINE_TUNE = input(0.962, type=input.float)  
ATR_CS = atr(ATR_CrossOver_Period)*ATR_SIGNAL_FINE_TUNE

StopLoss_Initial_Short = input(0.0, type=input.float) 
StopLoss_Initial_Long = input(0.0, type=input.float) 

StopLoss_Long_Adjust = input(0.0, type=input.float) 
StopLoss_Short_Adjust = input(0.0, type=input.float) 

VOLUME_CHECK = input(200)

//Custom Time Interval
fromMinute = input(defval = 0, title = "From Minute", minval = 0, maxval = 60)
fromHour = input(defval = 0, title = "From Hour", minval = 0, maxval = 24)
fromDay = input(defval = 1, title = "From Day", minval = 1)
fromMonth = input(defval = 1, title = "From Month", minval = 1)
fromYear = input(defval = 2019, title = "From Year", minval = 1900)
tillMinute = input(defval = 0, title = "Till Minute", minval = 0, maxval = 60)
tillHour = input(defval = 0, title = "Till Hour", minval = 0, maxval = 24)
tillDay = input(defval = 1, title = "Till Day", minval = 1)
tillMonth = input(defval = 1, title = "Till Month", minval = 1)
tillYear = input(defval = 2020, title = "Till Year", minval = 1900)
timestampStart = timestamp(fromYear,fromMonth,fromDay,fromHour,fromMinute)
timestampEnd = timestamp(tillYear,tillMonth,tillDay,tillHour,tillMinute)


//Custom Buy Signal Code --  This is where you design your own buy and sell signals. You now have millions of possibilites with the use of simple if/and/or statements.
if (  dir==1 and dir[1]==-1  and volume > VOLUME_CHECK and ((fsignal[1] -fsignal) <= 0) and  cross(fmacd, smacd) )
    strategy.exit("SELL")
    strategy.entry("BUY", strategy.long)
    strategy.exit("BUY_STOP","BUY", stop = close - StopLoss_Initial_Long)

//Custom Sell Signal Code
if  ( dir == -1 and dir[1] == 1 and dir[2] == 1 and dir[3] == 1 and dir[4] == 1 and  cross(fmacd, smacd) )
    strategy.exit( "BUY")
    strategy.entry("SELL", strategy.short)
    strategy.exit("SELL_STOP","SELL", stop = close + StopLoss_Initial_Short)

//Slight adjustments to ST for fine tuning
if (strategy.opentrades > 0 )
    strategy.exit("BUY_TRAIL_STOP","BUY", stop = longStop - StopLoss_Long_Adjust)
    strategy.exit("SELL_TRAIL_STOP","SELL", stop = shortStop + StopLoss_Short_Adjust)