동력 추적 및 트렌드 전략

저자:차오장, 2024-02-22 17:27:18
태그:

img

전반적인 설명

이 전략의 핵심 아이디어는 슈퍼 트렌드 지표와 평균 방향 움직임 지표 (ADX) 를 결합하여 트렌드를 판단하고 추적하는 것입니다. 슈퍼 트렌드 지표는 현재 가격 트렌드 방향을 식별하고 ADX는 트렌드 강도를 결정하는 데 사용됩니다. 거래는 강력한 트렌드 조건에서만 이루어집니다. 또한 전략은 촛불 몸 색깔, 거래량 및 기타 지표를 확인하기 위해 사용하여 비교적 완전한 거래 규칙을 형성합니다.

전체적으로 이 전략은 추세 추적 전략에 속하며, 중장기적, 명확한 추세를 파악하는 것을 목표로 하고 있으며, 통합 및 변동 기간의 간섭을 피합니다.

전략 원칙

  1. 슈퍼 트렌드 지표를 사용하여 가격 트렌드 방향을 결정하십시오. 가격이 슈퍼 트렌드 위에있을 때 그것은 긴 신호이며 슈퍼 트렌드 아래에있을 때 그것은 짧은 신호입니다.

  2. ADX를 사용하여 트렌드의 강도를 판단하십시오. ADX가 문턱보다 높을 때만 거래 신호가 생성되므로 명확하지 않은 통합 기간을 필터링 할 수 있습니다.

  3. 촛불 몸 색깔은 현재 상승 또는 하락 패턴에 있는지 판단하기 위해 Super Trend 지표와 결합하여 확인을 형성합니다.

  4. 거래량 증가는 확인 신호로 작용합니다. 거래량이 증가 할 때만 지위가 설정됩니다.

  5. 스톱 로스를 설정하고 이윤을 취해서 이윤을 확보하고 위험을 통제합니다.

  6. 하루가 끝날 때까지 모든 포지션을 닫으세요

전략 의 장점

  1. 중장기적, 명확한 트렌드를 추적하고, 변동을 피하고, 높은 수익성을 달성합니다.

  2. 이 전략은 몇 가지 매개 변수를 가지고 있으며 이해하기 쉽고 실행하기 쉽습니다.

  3. 스톱 로스로 리스크가 잘 통제되고 수익을 취합니다.

  4. 확인을 위해 여러 가지 지표를 사용하면 잘못된 신호를 줄일 수 있습니다.

전략 의 위험

  1. 시장 전체의 큰 수정에서 큰 손실을 입을 수 있습니다.

  2. 개별 주식은 근본적인 변화로 인해 급격한 반전을 겪을 수 있습니다.

  3. 블랙 스완 사건의 주요 정책 변경

해결책:

  1. ADX 매개 변수를 적절히 조정하여 강력한 트렌드 아래에서만 거래하도록 합니다.

  2. 단일 손실 금액을 제어하기 위해 중지 손실 비율을 높여

  3. 정책과 중요한 사건들을 면밀히 감시하고 필요한 경우 손실을 적극적으로 줄이세요.

최적화 위한 지침

  1. 슈퍼 트렌드 매개 변수들의 다양한 조합을 테스트하여 가장 안정적인 신호를 생성하는 것을 찾으십시오.

  2. 최적의 설정을 결정하기 위해 다양한 ADX 매개 변수 조합을 테스트합니다.

  3. 변동성, 볼링거 밴드 같은 다른 확인 지표를 추가하면 잘못된 신호를 더 많이 줄일 수 있습니다.

  4. 트렌드가 무너지면 적시에 손실을 줄이기 위해 브레이크업 전략과 결합하십시오.

요약

이 전략의 전반적인 논리는 명확하다. 슈퍼 트렌드를 사용하여 가격 트렌드 방향을 판단하고 ADX를 사용하여 트렌드 강도를 결정하고 강력한 트렌드를 따라 거래한다. 스톱 로스와 영업은 위험을 제어하기 위해 설정된다. 전략은 몇 가지 매개 변수를 가지고 있으며 최적화하기가 쉽습니다. 간단하고 효과적인 트렌드 추적 전략을 배우는 데 좋은 예로 사용될 수 있습니다. 매개 변수 최적화, 신호 필터링 등을 통해 추가 개선이 가능합니다.


/*backtest
start: 2023-02-15 00:00:00
end: 2024-02-21 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Intraday Strategy Template

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

//@version=4
strategy("[VJ]Hulk Smash Intra", overlay=true, calc_on_every_tick = false, pyramiding=0,default_qty_type=strategy.percent_of_equity, default_qty_value=100,initial_capital=2000)

// ********** Strategy inputs - Start **********

// Used for intraday handling
// Session value should be from market start to the time you want to square-off 
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session, 
     defval="0915-1455", confirm=true)

// Make inputs that set the take profit % (optional)
longProfitPerc = input(title="Long Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01

shortProfitPerc = input(title="Short Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01
     
// Set stop loss level with input options (optional)
longLossPerc = input(title="Long Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01

shortLossPerc = input(title="Short Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01    
     
var float i_multiplier = input(title = "ST Multiplier", type = input.float, 
     defval = 2, step = 0.1, confirm=true)

var int i_atrPeriod = input(title = "ST ATR Period", type = input.integer, 
     defval = 10, confirm=true)     
     
len = input(title="ADX Length", type=input.integer, defval=14)
th = input(title="ADX Threshold", type=input.integer, defval=20)
adxval = input(title="ADX Momemtum Value", type=input.integer, defval=25)     



// ********** Strategy inputs - End **********


// ********** Supporting functions - Start **********

// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0

// ********** Supporting functions - End **********


// ********** Strategy - Start **********

[superTrend, dir] = supertrend(i_multiplier, i_atrPeriod)

colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) : color.new(color.green, 100)


// Super Trend Long/short condition
stlong = close > superTrend
stshort = close < superTrend



// Figure out take profit price
longExitPrice  = strategy.position_avg_price * (1 + longProfitPerc)
shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)

// Determine stop loss price
longStopPrice  = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)

//Vol Confirmation
vol = volume > volume[1]


//Candles colors
greenCandle = (close > open)
redCandle = (close < open)

// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)

// Trade only if intraday session is active




TrueRange = max(max(high - low, abs(high - nz(close[1]))), abs(low - nz(close[1])))
DirectionalMovementPlus = high - nz(high[1]) > nz(low[1]) - low ? max(high - nz(high[1]), 0) : 0
DirectionalMovementMinus = nz(low[1]) - low > high - nz(high[1]) ? max(nz(low[1]) - low, 0) : 0


SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - nz(SmoothedTrueRange[1]) / len + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - 
   nz(SmoothedDirectionalMovementPlus[1]) / len + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - 
   nz(SmoothedDirectionalMovementMinus[1]) / len + DirectionalMovementMinus

DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus - DIMinus) / (DIPlus + DIMinus) * 100
ADX = sma(DX, len)

// a = plot(DIPlus, color=color.green, title="DI+", transp=100)
// b = plot(DIMinus, color=color.red, title="DI-", transp=100)

//Final Long/Short Condition
longCondition = stlong and redCandle and vol and ADX>adxval
shortCondition = stshort and greenCandle and vol and ADX >adxval



//Long Strategy - buy condition and exits with Take profit and SL
if (longCondition and intradaySession)
    stop_level = longStopPrice
    profit_level = longExitPrice
    strategy.entry("My Long Entry Id", strategy.long)
    strategy.exit("TP/SL", "My Long Entry Id",stop=stop_level, limit=profit_level)
    


//Short Strategy - sell condition and exits with Take profit and SL
if (shortCondition and intradaySession)
    stop_level = shortStopPrice
    profit_level = shortExitPrice
    strategy.entry("My Short Entry Id", strategy.short)
    strategy.exit("TP/SL", "My Short Entry Id", stop=stop_level, limit=profit_level)
    
 
 
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")

// ********** Strategy - End **********

더 많은