이중 ATR 채널 트렌드 전략

저자:차오장, 날짜: 2023-11-01 11:40:07
태그:

img

전반적인 설명

이중 ATR 채널 트렌드 추적 전략은 트렌드 추적 전략으로 이동 평균, ATR 채널 및 여러 기술적 지표를 결합하여 트렌드가 확립된 후 트렌드를 추적합니다.

어떻게 작동 합니까?

이 전략은 트렌드 방향을 결정하는 주요 이동 평균 지표로 키 라인을 사용합니다. 또한 가격 활동 범위를 제한하기 위해 ATR 채널을 통합합니다. 가격이 상위 대역 근처에있을 때 길게 가지 않고 가격이 하위 대역 근처에있을 때 짧게 가지 않고 새로운 최고치를 추구하고 판매 하락을 피합니다.

키준 라인이 상향 크로스오버를 가질 때 구매 신호가 생성됩니다. 하향 크로스오버가 발생하면 판매 신호가 트리거됩니다. 잘못된 신호를 필터링하기 위해 전략은 또한 아론, RSI, MACD 및 PSAR을 포함한 여러 기술적 인 지표를 확인합니다. 모든 확인 조건이 충족되면 구매 또는 판매 신호가 트리거됩니다.

일단 거래에 들어가면 전략은 포지션을 관리하기 위해 스톱 로스를 사용하고 이익을 취합니다. 스톱 로스는 0.5 ATR로 설정되고 이익은 0.5%로 설정됩니다. 가격이 다시 반대 방향으로 키 라인을 넘으면 포지션은 즉시 종료됩니다.

장점

  • 트렌드를 결정하기 위해 키 라인을 사용하는 것은 범위에 묶인 시장에 의해 휘파람을 피할 수 있습니다.
  • ATR 채널은 더 나은 위험 통제를 위해 가격 활동을 제한합니다.
  • 여러 번 확인하면 잘못된 신호가 많이 줄어듭니다.
  • 리스크를 관리하는 동안 수익에 스톱 로스 및 영업 로크를 통합하는 것

위험성

  • 여러 가지 확인에서 지연된 신호, 초기 트렌드 움직임을 놓칠 수 있습니다.
  • 작은 스톱 손실은 자주 중단 될 수 있습니다.
  • 열악한 키 및 ATR 매개 변수는 많은 잘못된 신호를 생성 할 수 있습니다.
  • 매개 변수 최적화 및 곡선 적합성에 의존하는 것은 라이브 거래에서 잘 작동하지 않을 수 있습니다.

개선 할 기회

  • 이치모쿠 구름과 같은 더 고급 트렌드 지표를 테스트
  • 더 나은 리스크 보상 비율을 위해 스톱 로스를 최적화하고 수익 포인트를 취하십시오.
  • 다른 시장에 최적의 매개 변수를 찾아
  • 실시간 시장 조건에 기반한 매개 변수 동적 조정 추가
  • 확인 지표의 다른 조합을 테스트합니다.
  • 전략의 안정성을 보장하기 위해 지속적으로 최적화

결론

이중 ATR 채널 트렌드 추후 전략은 이동 평균, ATR 채널 및 여러 기술적 지표를 결합하여 일단 트렌드의 방향으로 거래합니다. 단일 지표 전략과 비교하면 신호 품질과 승률을 크게 향상시킬 수 있습니다. 스톱 로스 및 영리 메커니즘은 위험을 제어합니다. 매개 변수 최적화 및 조합 테스트를 통해이 전략은 안정적인 수익을 얻을 수 있습니다. 그러나 역사적 데이터에 의존하는 것이 걱정이며 라이브 성능은 추가 검증이 필요합니다. 지속적인 최적화는 탄력성을 보장하는 열쇠입니다.


/*backtest
start: 2023-10-24 00:00:00
end: 2023-10-27 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// strategy(title="NoNonsense Forex", overlay=true, default_qty_value=100000, initial_capital=100)

//////////////////////
////// BASELINE //////
//////////////////////
ma_slow_type = input(title="Baseline Type", type=input.string, defval="Kijun", options=["ALMA", "EMA", "DEMA", "TEMA", "WMA", "VWMA", "SMA", "SMMA", "HMA", "LSMA", "Kijun", "McGinley"])
ma_slow_src = close //input(title="MA Source", type=input.source, defval=close)
ma_slow_len = input(title="Baseline Length", type=input.integer, defval=20)
ma_slow_len_fast = input(title="Baseline Length Fast", type=input.integer, defval=12)

lsma_offset  = input(defval=0, title="* Least Squares (LSMA) Only - Offset Value", minval=0)
alma_offset  = input(defval=0.85, title="* Arnaud Legoux (ALMA) Only - Offset Value", minval=0, step=0.01)
alma_sigma   = input(defval=6, title="* Arnaud Legoux (ALMA) Only - Sigma Value", minval=0)

ma(type, src, len) =>
    float result = 0
    if type=="SMA" // Simple
        result := sma(src, len)
    if type=="EMA" // Exponential
        result := ema(src, len)
    if type=="DEMA" // Double Exponential
        e = ema(src, len)
        result := 2 * e - ema(e, len)
    if type=="TEMA" // Triple Exponential
        e = ema(src, len)
        result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)
    if type=="WMA" // Weighted
        result := wma(src, len)
    if type=="VWMA" // Volume Weighted
        result := vwma(src, len) 
    if type=="SMMA" // Smoothed
        w = wma(src, len)
        result := na(w[1]) ? sma(src, len) : (w[1] * (len - 1) + src) / len
    if type=="HMA" // Hull
        result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
    if type=="LSMA" // Least Squares
        result := linreg(src, len, lsma_offset)
    if type=="ALMA" // Arnaud Legoux
        result := alma(src, len, alma_offset, alma_sigma)
    if type=="Kijun" //Kijun-sen
        kijun = avg(lowest(len), highest(len))
        result :=kijun
    if type=="McGinley"
        mg = 0.0
        mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4))
        result :=mg
    result

baseline = ma(ma_slow_type, ma_slow_src, ma_slow_len)
plot(baseline, title='Baseline', color=rising(baseline,1) ? color.green : falling(baseline,1) ? color.maroon : na, linewidth=3)

//////////////////
////// ATR ///////
//////////////////
atrlength=input(14, title="ATR Length")
one_atr=rma(tr(true), atrlength)
upper_atr_band=baseline+one_atr
lower_atr_band=baseline-one_atr
plot(upper_atr_band, color=color.gray, style=plot.style_areabr, transp=95, histbase=50000, title='ATR Cave')
plot(lower_atr_band, color=color.gray, style=plot.style_areabr, transp=95, histbase=0, title='ATR Cave')
plot(upper_atr_band, color=close>upper_atr_band ? color.fuchsia : na, style=plot.style_line, linewidth=5, transp=50, title='Close above ATR cave')
plot(lower_atr_band, color=close<lower_atr_band ? color.fuchsia : na, style=plot.style_line, linewidth=5, transp=50, title='Close below ATR cave')
donttradeoutside_atrcave=input(true)
too_high = close>upper_atr_band and donttradeoutside_atrcave
too_low = close<lower_atr_band and donttradeoutside_atrcave

////////////////////////////
////// CONFIRMATION 1 ////// the trigger actually
////////////////////////////
lenaroon = input(8, minval=1, title="Length Aroon")
c1upper = 100 * (highestbars(high, lenaroon+1) + lenaroon)/lenaroon
c1lower = 100 * (lowestbars(low, lenaroon+1) + lenaroon)/lenaroon
c1CrossUp=crossover(c1upper,c1lower)
c1CrossDown=crossunder(c1upper,c1lower)


////////////////////////////////
////// CONFIRMATION: MACD //////
////////////////////////////////
dont_use_macd=input(false)
macd_fast_length = input(title="Fast Length", type=input.integer, defval=13)
macd_slow_length = input(title="Slow Length", type=input.integer, defval=26)
macd_signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
macd_fast_ma = ema(close, macd_fast_length)
macd_slow_ma = ema(close, macd_slow_length)
macd = macd_fast_ma - macd_slow_ma
macd_signal = ema(macd, macd_signal_length)
macd_hist = macd - macd_signal

macdLong=macd_hist>0 or dont_use_macd
macdShort=macd_hist<0 or dont_use_macd

/////////////////////////////
///// CONFIRMATION: RSI /////
/////////////////////////////
dont_use_rsi=input(false)
lenrsi = input(14, minval=1, title="RSI Length") //14
up = rma(max(change(close), 0), lenrsi)
down = rma(-min(change(close), 0), lenrsi)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiLong=rsi>50 or dont_use_rsi
rsiShort=rsi<50 or dont_use_rsi

//////////////////////////////
///// CONFIRMATION: PSAR /////
//////////////////////////////
dont_use_psar=input(false)
psar_start = input(0.03, step=0.01)
psar_increment = input(0.018, step=0.001)
psar_maximum = input(0.11, step=0.01) //default 0.08
psar = sar(psar_start, psar_increment, psar_maximum)

plot(psar, style=plot.style_cross, color=color.blue, title='PSAR')
psarLong=close>psar or dont_use_psar
psarShort=close<psar or dont_use_psar

/////////////////////////
///// CONFIRMATIONS /////
/////////////////////////
Long_Confirmations=psarLong and rsiLong and macdLong
Short_Confirmations=psarShort and rsiShort and macdShort

GoLong=c1CrossUp and Long_Confirmations and not too_high
GoShort=c1CrossDown and Short_Confirmations and not too_low

////////////////////
///// STRATEGY /////
////////////////////

use_exit=input(false)
KillLong=c1CrossDown and use_exit
KillShort=c1CrossUp and use_exit

SL=input(0.5, step=0.1)/syminfo.mintick
TP=input(0.005, step=0.001)/syminfo.mintick

strategy.entry("nnL", strategy.long, when = GoLong)
strategy.entry("nnS", strategy.short, when = GoShort)
strategy.exit("XL-nn", from_entry = "nnL", loss = SL, profit=TP)
strategy.exit("XS-nn", from_entry = "nnS", loss = SL, profit=TP)
strategy.close("nnL", when = KillLong)
strategy.close("nnS", when = KillShort)



더 많은