ATR 및 T3 이동 평균 전략

저자:차오장, 날짜: 2023-09-17 18:30:48
태그:

전반적인 설명

이 전략은 트렌드 결정 및 추적을 위해 ATR 및 T3 이동 평균을 결합합니다. ATR은 전반적인 트렌드 방향을 판단하기 위해 가격 채널을 형성합니다. T3 이동 평균은 입구 신호와 스톱 손실 출구 지점을 제공합니다. 전략은 안정적인 이익을 추구하는 트렌드 추종자에게 적합합니다.

전략 논리

  1. ATR은 가격 채널을 형성하고 채널 방향은 주요 트렌드를 결정합니다.

  2. T3 이동 평균은 특정 입시 시기를 결정하는 데 도움이 됩니다.

  3. 하위 범위를 넘어가는 가격이 손실을 멈추는 것을 유발합니다. 상위 범위를 넘어가는 것은 이익을 가져옵니다.

  4. 단장 또는 쌍방향 거래를 위한 옵션

  5. 최적의 설정을 찾기 위해 지표 성격과 함께 파라미터 최적화.

이점 분석

  1. ATR 채널은 트렌드 식별과 방향을 명확하게 보여줍니다.

  2. 각기 다른 레벨의 트렌드를 파악하기 위한 조절 가능한 T3 매개 변수

  3. 일관성 있는 스톱 로스 및 취득 규칙은 임의의 출구를 피합니다.

  4. 낮은 거래 빈도는 장기 보유 전략에 적합합니다.

위험 분석

  1. 지표의 오차는 잘못된 거래를 일으킬 수 있습니다.

  2. 개별 주식 변동성 패턴을 고려하지 않는 것은 과도한 적합성 위험이 있습니다.

  3. 낮은 거래 빈도는 기회를 놓치고 수익 잠재력을 제한할 위험이 있습니다.

  4. 무거운 포지션 보유는 일말 미끄러짐 위험을 초래합니다.

최적화 방향

  1. 거래 유효성을 보장하기 위해 다른 지표를 추가합니다.

  2. 다른 제품에 대한 매개 변수 조정은 적응력을 향상시킵니다.

  3. 포지션 사이즈를 최적화하여 빈도와 위험을 균형 잡습니다.

  4. 이윤 공간을 확장하기 위해 동적인 트레일링 스톱 로스 및 이윤 취득을 고려하십시오.

  5. 안정성을 높이기 위해 전략 레벨 필터를 추가합니다.

요약

이 전략은 ATR와 T3 이동 평균을 통합하여 간단하고 효과적인 트렌드 추적을 수행합니다. 그러나 지표 논리 및 매개 변수 최적화에 대한 추가 개선은 오류를 줄이고 더 실용화 할 수 있습니다.


/*backtest
start: 2023-09-09 00:00:00
end: 2023-09-16 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
//Author - CryptoJoncis
strategy("ATR and T3 strategy", shorttitle="AT3S_CryptoJoncis", overlay=true)

shorting = input(false, title="shorts on?")
precentage_diff = input(5,title="Precantage")/100
Lengthx = input(25, title="Lenght of T3")

//For best results use 0.7 or 0.618
Vfactx = input(0.72, minval=0.01,step=0.01, title="Volume Factor of T3 with HA source")

Source_of_T3_Normal = close
Source_of_T3 =  Source_of_T3_Normal 
FirstEMAx = ema(Source_of_T3, Lengthx)
SecondEMAx = ema(FirstEMAx, Lengthx)
ThirdEMAx = ema(SecondEMAx, Lengthx)
FourthEMAx = ema(ThirdEMAx, Lengthx)
FifthEMAx = ema(FourthEMAx, Lengthx)
SixthEMAx = ema(FifthEMAx, Lengthx)

//Doing all the calculations which are from 
c1x = -Vfactx*Vfactx*Vfactx
c2x = 3*Vfactx*Vfactx + 3*Vfactx*Vfactx*Vfactx
c3x = -6*Vfactx*Vfactx -3*Vfactx -3*Vfactx*Vfactx*Vfactx
c4x = 1 + 3*Vfactx + Vfactx*Vfactx*Vfactx + 3*Vfactx*Vfactx

//Assigning EMAS to T3 Moving average
T3MAx = c1x * SixthEMAx + c2x * FifthEMAx + c3x * FourthEMAx + c4x * ThirdEMAx

color_of_Tilson_Moving_Average = T3MAx > T3MAx[1] ? lime : red
plot(T3MAx, title="Tilson Moving Average(ema)", color=color_of_Tilson_Moving_Average)

t_up = T3MAx + (T3MAx * precentage_diff)
t_dn = T3MAx - (T3MAx * precentage_diff)

x=plot(t_up, color=color_of_Tilson_Moving_Average)
z=plot(t_dn, color=color_of_Tilson_Moving_Average)
fill(x,z, color= T3MAx[1] < T3MAx ? lime : gray)

Factor=input(5, minval=1)
Pd=input(5, minval=1)
//

Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))


TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown

linecolor = Trend == 1 ? green : red
//
b=plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "")

Factor1=input(1, minval=1)
Pd1=input(1, minval=1)
//

Up1=hl2-(Factor1*atr(Pd1))
Dn1=hl2+(Factor1*atr(Pd1))


TrendUp1=close[1]>TrendUp1[1]? max(Up1,TrendUp1[1]) : Up1
TrendDown1=close[1]<TrendDown1[1]? min(Dn1,TrendDown1[1]) : Dn1

Trend1 = close > TrendDown1[1] ? 1: close< TrendUp1[1]? -1: nz(Trend1[1],1)
Tsl1 = Trend1==1? TrendUp1: TrendDown1

linecolor1 = Trend1 == 1 ? green : red
//
a=plot(Tsl1, color = linecolor1 , style = line , linewidth = 2,title = "")

long = (close > Tsl and close > Tsl1 and close > T3MAx)

short = (close < Tsl and close < Tsl1 and close < T3MAx)

if(shorting==true)
    strategy.entry("MacdSE", strategy.short, comment="Open Short", when=short)
    strategy.entry("MacdLE", strategy.long, comment="Open Long", when=long)
    strategy.close("MacdLE", when=hl2 < t_dn)
    strategy.close("MacdSE", when=hl2 > t_up)
if(shorting==false)
    strategy.entry("MacdLE", strategy.long, comment="Open Long", when=long)
    strategy.close("MacdLE", when=hl2 < t_dn)
fill(a,b,color=linecolor)



더 많은