이치모쿠 클라우드, MACD 및 스토캐스틱을 기반으로 한 다중 시간 프레임 추세 추종 전략


생성 날짜: 2024-02-05 10:30:45 마지막으로 수정됨: 2024-02-05 10:30:45
복사: 2 클릭수: 768
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이치모쿠 클라우드, MACD 및 스토캐스틱을 기반으로 한 다중 시간 프레임 추세 추종 전략

개요

이 전략은 이치모쿠 클라우드 그래프, 이동 평균, MACD, 스토카스틱 및 ATR과 같은 여러 지표들을 결합하여 여러 시간 프레임에 대한 트렌드 식별 및 추적을 가능하게 한다. 높은 확률의 트렌드 신호를 얻은 후, ATR 주기 상쇄 스톱 방식을 사용하여 위험 통제를 한다.

전략 원칙

  1. 이치모쿠 구름 도표는 중장선 트렌드 방향을 판단한다. CLOSE 가격 위쪽을 가로질러 구름 도표의 회전선과 기준선이 다중선 신호이고 아래쪽을 가로질러 공백선 신호이다.

  2. MACD는 단선 트렌드와 오버 바이 오버 셀 상황을 판단한다. MACD 기둥선 상부 횡단 신호선은 다중 머리 신호이며, 아래 횡단 신호선은 공백 신호이다.

  3. Stochastic KD는 오버 바이 오버 세일 영역을 판단한다. K선 상단 20은 다목표 신호이며, 하단 80은 공목표 신호이다.

  4. 이동 평균은 중기 트렌드를 판단한다. 종결 가격 상단에는 이동 평균이 다단계 신호로, 하단에는 공백 신호로 착용한다.

  5. 위와 같은 여러 지표 신호를 통합하여 일부 가짜 신호를 필터링하여 높은 확률의 지속적인 트렌드 신호를 형성한다.

  6. ATR을 기반으로 스톱 가격을 계산한다. 특정 ATR 배수를 스톱 및 스톱포인트로 사용하여 리스크 관리를 한다.

전략적 이점

  1. 여러 시간 프레임의 트렌드를 인식하여 신호의 정확도를 향상시킵니다.

  2. 지표 조합 필터링 기술이 널리 사용되어 가짜 신호를 효과적으로 필터링한다.

  3. ATR 주기적 중지 손실 차단, 단일 손실을 최대한 제어한다.

  4. 다양한 위험 선호도를 충족시키기 위해 엄격한 입학 조건을 사용자 정의 할 수 있습니다.

전략적 위험

  1. 트렌드 트래킹에 의존하여 갑작스러운 사건으로 인한 반전을 식별할 수 없습니다.

  2. ATR 주기적 상실은 너무 이상화되어 있을 수 있으며, 실 디스크에서 완전히 복제하기는 어려울 것이다.

  3. 파라미터를 잘못 설정하면 거래 빈도가 너무 높거나 신호 인식 정확도가 떨어질 수 있습니다.

  4. 다른 품종과 시장 환경에 적응하기 위해 매개 변수를 조정해야 합니다.

전략 최적화 방향

  1. 트렌드 전환점을 판단하는 데 도움이 되는 기계 학습 알고리즘을 추가합니다.

  2. ATR 배수 파라미터를 최적화, 다른 품종은 다른 배수를 설정할 수 있다.

  3. 거래량 변화와 같은 다른 요소와 결합하여, 브레이크 신호의 정확도를 향상시킵니다.

  4. 피드백 결과에 따라 계속 최적화하고, 최적의 파라미터 조합을 찾습니다.

요약하다

이 전략은 Ichimoku 클라우드 그래프, MACD, Stochastic 등 여러 지표를 통합하여 여러 시간 프레임의 트렌드 식별을 수행하며, 트렌드를 파악하면서 갑작스러운 사건의 포획을 피합니다. ATR 주기적 손실 중지 방식은 단기 손실을 효과적으로 제어하는 바람직한 트렌드 추적 전략입니다.

전략 소스 코드
/*backtest
start: 2024-01-05 00:00:00
end: 2024-02-04 00:00:00
period: 4h
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/
// © FXFUNDINGMATE

//@version=4
strategy(title="FXFUNDINGMATE TREND INDICATOR", overlay=true)

//Ichimoku Cloud
conversionPeriods = input(9, minval=1, title="Conversion Line Length")
basePeriods = input(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Length")
displacement = input(26, minval=1, title="Displacement")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)[displacement - 1]
leadLine2 = donchian(laggingSpan2Periods)[displacement - 1]


//macd
fast_length = input(title="Fast Length", type=input.integer, defval=12)
slow_length = input(title="Slow Length", type=input.integer, defval=26)
src = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
sma_source = input(title="Simple MA (Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="Simple MA (Signal Line)", type=input.bool, defval=false)

fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)
slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal


//kd
periodK = input(5, title="%K Length", minval=1)
smoothK = input(3, title="%K Smoothing", minval=1)
periodD = input(3, title="%D Smoothing", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)


//atr
atrlength = input(title="Atr Length", defval=8, minval=1)
SMulti = input(title="Stop loss multi Atr", defval=1.0)
TMulti = input(title="Take profit multi Atr", defval=1.0)
smoothing = input(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])
ma_function(source, length) =>
	if smoothing == "RMA"
		rma(source, length)
	else
		if smoothing == "SMA"
			sma(source, length)
		else
			if smoothing == "EMA"
				ema(source, length)
			else
				wma(source, length)
atr = ma_function(tr(true), atrlength)


operation_type = input(defval = "Both", title = "Position side", options = ["Long", "Short", "Both"])
operation = operation_type == "Long" ? 1 : operation_type == "Short" ? 2 : 3
showlines = input(true,  title="Show sl&tp lines")

// MA
sma_len = input(100, title="MA Length", type=input.integer)
sma = sma(close, sma_len)

longCond = crossover(k, 20) and macd > 0 and close > sma and close > leadLine1 and close > leadLine2
shortCond = crossunder(k, 80)  and macd < 0 and close < sma and close < leadLine1 and close < leadLine2

entry_price  = float(0.0) //set float
entry_price := strategy.position_size != 0 or longCond or shortCond ? strategy.position_avg_price : entry_price[1]
entry_atr = valuewhen(longCond or shortCond, atr,0)
short_stop_level     = float(0.0)   //set float
short_profit_level   = float(0.0)   //set float
long_stop_level      = float(0.0)   //set float
long_profit_level    = float(0.0)   //set float
short_stop_level    := entry_price + SMulti * entry_atr
short_profit_level  := entry_price - TMulti * entry_atr
long_stop_level     := entry_price - SMulti * entry_atr
long_profit_level   := entry_price + TMulti * entry_atr


//  Strategy Backtest Limiting Algorithm
i_startTime = input(defval = timestamp("1 Jan 2020 00:00 +0000"), title = "Backtesting Start Time", type = input.time)
i_endTime = input(defval = timestamp("31 Dec 2025 23:59 +0000"), title = "Backtesting End Time", type = input.time)
timeCond = true

if (operation == 1 or operation == 3)
    strategy.entry("long" , strategy.long , when=longCond and timeCond, alert_message = "Long")
    strategy.exit("SL/TP", from_entry = "long" , limit = long_profit_level , stop = long_stop_level , alert_message = "Long exit")

if (operation == 2 or operation == 3)
    strategy.entry("short", strategy.short, when=shortCond and timeCond, alert_message="Short")
    strategy.exit("SL/TP", from_entry = "short", limit = short_profit_level , stop = short_stop_level , alert_message = "Short exit")
    
if time > i_endTime  
    strategy.close_all(comment = "close all", alert_message = "close all")
    
plot(showlines and strategy.position_size <= 0 ? na : long_stop_level,    color=color.red,  style=plot.style_linebr, linewidth = 2)
plot(showlines and strategy.position_size <= 0 ? na : long_profit_level,  color=color.lime, style=plot.style_linebr, linewidth = 2)
plot(showlines and strategy.position_size >= 0 ? na : short_stop_level,   color=color.red,  style=plot.style_linebr, linewidth = 2)
plot(showlines and strategy.position_size >= 0 ? na : short_profit_level, color=color.lime, style=plot.style_linebr, linewidth = 2)

//}