더블 슈퍼텐드와 MACD 조합 트레이딩 전략


생성 날짜: 2023-09-26 17:45:03 마지막으로 수정됨: 2023-09-26 17:45:03
복사: 0 클릭수: 1606
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이중 슈퍼트렌드와 MACD 조합 거래 전략은 두 가지 트렌드 추적 지표 ((SuperTrend 1과 SuperTrend 2) 와 한 가지 동력 흔들림 지표 ((MACD) 를 결합하여 주관적 판단 없이 일관된 시스템 거래 방법을 제공하기위한 것입니다.

이 전략의 핵심 장점은:

  • 이중 수퍼트렌드 검증: 두 개의 수퍼트렌드 지표를 사용하여 ATR 주기와 인자가 다르므로 트렌드 방향을 확인할 수 있으며, 이중 검증 메커니즘은 잘못된 신호를 줄일 수 있습니다.

  • 동력 확인:MACD 기둥 선은 동력 필터로써, 입출구를 확인하고, 인증 계층을 추가한다.

  • 객관적인 입출장: 전략은 트렌드 방향과 동력 조합에 따라 매매 신호를 생성하며, 주관적인 해석이 없다.

  • 자동화 거래 관리: 전략 내장 수수료, 슬라이드 포인트 및 초기 자본 설정, 자동화 거래 실행.

  • 사용자 정의: 모든 매개 변수는 다양한 거래자의 요구와 변화하는 시장 환경에 적응하기 위해 쉽게 사용자 정의됩니다.

원칙

이 전략은 명확한 규칙에 따라 작동하며, 두 개의 슈퍼 트렌드가 확인된 트렌드 방향과 MACD 기둥이 표시된 동력에 초점을 맞추고 있습니다.

참가 규칙

  • 다단 입구: 두 개의 슈퍼트렌드 지표가 다단이고 MACD 기둥이 0보다 크다.

  • 공백 입구: 두 개의 SuperTrend 지표 공백과 MACD 기둥선은 0보다 작다.

출전 규칙

  • 평다리 포지션: 어떤 슈퍼트렌드 회전기 또는 MACD 기둥선 회전기.

  • 평평한 포지션: 어떤 슈퍼트렌드 회전도 다목적이거나 MACD 기둥선 회전이 된다.

거래 관리

  • 전략은 고정 수수료 비율과 슬라이드 포인트 매개 변수를 사용합니다.

  • 내장된 자동 위험 관리 기능으로 과도한 틈을 피한다.

거래 방향

이 전략은 많은 공백 쌍방향 거래를 허용한다. 사용자는 자신의 시장에 따라 거래 방향을 선택할 수 있다.

사용 설명

  • 트렌드가 뚜렷한 시기가 가장 적합하다.

  • 사용자는 필요에 따라 SuperTrend의 ATR 주기, 인자 및 MACD 매개 변수를 조정할 수 있다.

기본 변수

  • 슈퍼트렌드 1 ATR 주기:10

  • 슈퍼트렌드 1 인수:3.0

  • 슈퍼트렌드 2 ATR 주기:20

  • 슈퍼트렌드 2 인자:5.0

  • MACD 단선 주기:12

  • MACD 느린 선주기:26

  • MACD 평형 주기:9

  • 수수료 비율: 0.1%

  • 슬라이드 포인트: 1

  • 거래 방향: 양방향

기본 매개 변수는 균형 잡힌 거래 방법을 제공하지만 개인 취향에 따라 사용자 정의 할 수 있습니다.

우위 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 이중 트렌드 검증으로 가짜 신호가 줄어들었다

두 개의 슈퍼트렌드 지표를 사용하여 트렌드 검증을하면 단일 지표로 인한 잘못된 신호를 크게 줄일 수 있습니다. 쌍성 확인 메커니즘은 안정성을 향상시킵니다.

  1. MACD 동적 필터링의 정확도 향상

MACD 기둥선은 보조 판단 기준으로, 일부 바람직하지 않은 거래 신호를 필터링하여 입금 정확도를 향상시킵니다.

  1. 철수 통제 능력이 강하다

양 트렌드 지표 조합으로, 트렌드 전환 시 빠르게 멈출 수 있으며, 회귀를 제어하는 데 도움이 된다.

  1. 자동화 수준이 높고, 주관적인 판단이 필요없습니다.

명확한 입출장 규칙, 내장 거래 관리 설정, 주관적 판단이 필요없고, 인적 오류를 줄여줍니다.

  1. 맞춤형, 적응력

지표 파라미터는 조정 가능하며, 다양한 품종과 거래 선호도에 맞게 최적화 할 수 있으며, 사용 범위는 넓다.

위험과 최적화

이 전략에는 다음과 같은 위험도 있습니다.

  1. 다중공간 동적 전환의 어려움

양 트렌드 지표 조합, 다공간 전환은 상대적으로 어렵고, 자주 방향을 바꾸는 시장에 적합하지 않다.

  1. 철수 통제 능력 제한

강세를 보인다면, 정지 가격이 뒤쳐져 확장의 위험을 철회할 수 있다.

  1. 비상사태에 대처할 수 없습니다.

“미국에서는 블랙 스완 사건에 대해 신속하게 대응할 수 없어서 철수할 위험이 더 크다”.

최적화 방향:

  1. 다양한 품종에 적응할 수 있도록 지표 파라미터를 최적화한다.

  2. 이동식 중지와 같은 손해 방지 장치를 추가하여 회수 제어.

  3. 다른 지표와 함께, 돌발사고를 식별하고, 회수율을 낮출 수 있습니다.

요약하다

요약하자면, 이중 슈퍼 트렌드와 MACD 조합 전략은 트렌드 추적과 동력 분석의 장점을 결합하고, 규칙이 명확하고, 자동화가 높으며, 노이즈 트레이딩 신호를 효과적으로 필터링 할 수 있으며, 매우 강력한 실용성을 가지고 있습니다. 그러나 회수 제어 및 변수 최적화 문제에 대해서도 주의해야합니다.

전략 소스 코드
/*backtest
start: 2023-09-18 00:00:00
end: 2023-09-25 00:00:00
period: 30m
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/
// © PresentTrading

//@version=5
// Define the strategy settings
// strategy("Dual-Supertrend with MACD - Strategy [presentTrading]", overlay=true, precision=3, default_qty_type=strategy.cash, 
//  commission_value= 0.1, commission_type=strategy.commission.percent, slippage= 1, 
//   currency=currency.USD, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, initial_capital= 10000)

// Trading Direction Dropdown
tradeDirection = input.string("both", "Trading Direction", options=["long", "short", "both"])

// MACD Inputs
fast_length = input(12, "Fast Length")
slow_length = input(26, "Slow Length")
signal_length = input(9, "Signal Smoothing")
sma_source = input.string("EMA", "Oscillator MA Type", options=["SMA", "EMA"])
sma_signal = input.string("EMA", "Signal Line MA Type", options=["SMA", "EMA"])


// MACD Calculation
fast_ma = sma_source == "SMA" ? ta.sma(close, fast_length) : ta.ema(close, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(close, slow_length) : ta.ema(close, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal

// Input Parameters for Supertrend 1
atrPeriod1 = input(10, "ATR Length for Supertrend 1")
factor1 = input.float(3.0, "Factor for Supertrend 1", step=0.01)

// Supertrend Calculation for 1
[supertrend1, direction1] = ta.supertrend(factor1, atrPeriod1)

// Input Parameters for Supertrend 2
atrPeriod2 = input(20, "ATR Length for Supertrend 2")
factor2 = input.float(5.0, "Factor for Supertrend 2", step=0.01)

// Supertrend Calculation for 2
[supertrend2, direction2] = ta.supertrend(factor2, atrPeriod2)

// Combined Conditions
isBullish = direction1 < 0 and direction2 < 0 and hist > 0
isBearish = direction1 > 0 and direction2 > 0 and hist < 0
exitLong = direction1 > 0 or direction2 > 0 or hist < 0
exitShort = direction1 < 0 or direction2 < 0 or hist > 0

// Strategy Entry and Exit based on Trading Direction
if (tradeDirection == "both" or tradeDirection == "long")
    strategy.entry("Buy", strategy.long, when=isBullish)
    strategy.close("Buy", when=exitLong)

if (tradeDirection == "both" or tradeDirection == "short")
    strategy.entry("Sell", strategy.short, when=isBearish)
    strategy.close("Sell", when=exitShort)

bodyMiddle1 = plot((open + close) / 2, display=display.none)
upTrend1 = plot(direction1 < 0 ? supertrend1 : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend1 = plot(direction1 < 0? na : supertrend1, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle1, upTrend1, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle1, downTrend1, color.new(color.red, 90), fillgaps=false)

bodyMiddle2 = plot((open + close) / 2, display=display.none)
upTrend2 = plot(direction2 < 0 ? supertrend2 : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend2 = plot(direction2 < 0? na : supertrend2, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle2, upTrend2, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle2, downTrend2, color.new(color.red, 90), fillgaps=false)