TEMA 이동 평균 교차 거래 전략


생성 날짜: 2023-09-12 16:40:50 마지막으로 수정됨: 2023-09-12 16:40:50
복사: 1 클릭수: 721
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략은 두 개의 다른 기간의 TEMA 지표를 사용하여 교차 거래하여 중간 기간의 가격 추세를 포착합니다. TEMA 지표는 가격 소음을 효과적으로 필터링하여 트렌드 반전을 식별합니다.

전략적 원칙:

  1. 각각 빠르게 천천히 두 개의 TEMA 평균선을 계산한다. 전형적인 변수는 빠른 선 5주기, 느린 선 8주기이다.

  2. 빠른 선이 아래쪽에서 느린 선을 뚫을 때, 여러 작업을 수행한다.

  3. 빠른 라인이 위쪽에서 아래로 느린 라인을 돌파할 때, 공백 평정 상태의 작업을 수행한다.

  4. K선 엔티티의 방향에 따라 필터링할 수 있으며, 역거래를 피한다.

  5. 역주기를 설정하여 역사 거래 신호를 모의합니다.

이 전략의 장점:

  1. TEMA 지표는 가격 소음을 필터링합니다.

  2. TEMA는 중간주기 동향을 파악할 수 있습니다.

  3. 방향 필터링은 역전도 포지션을 피하고 승률을 높일 수 있다.

이 전략의 위험은:

  1. TEMA는 여전히 지연되고 있으며, 최고의 입학 시점을 놓칠 수 있습니다.

  2. 최적의 매칭을 얻기 위해 파라미터 조합을 최적화해야 합니다.

  3. “음악학교”는 계속적으로 신호를 받을 수 없었습니다.

요약하자면, 이 전략은 두 개의 TEMA 교차로 거래를 추적하고, 잡음을 효과적으로 필터링하여 안정성을 향상시킬 수 있다. 그러나 TEMA 낙후 문제는 여전히 존재하며, 시장의 속도에 부응하기 위해 매개 변수를 최적화해야 한다.

전략 소스 코드
/*backtest
start: 2022-09-11 00:00:00
end: 2023-09-11 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Tema",overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075)
startP = timestamp(input(2017, "Start Year"), input(12, "Start Month"), input(17, "Start Day"), 0, 0)
end   = timestamp(input(9999, "End Year"),   input(1, "End Month"),   input(1, "End Day"),   0, 0)
_testPeriod() =>
    iff(time >= startP and time <= end, true, false)

tema_length_1 = input(5, "Fast TEMA")
tema_length_2 = input(8, "Slow TEMA")
usedir       = input(true, "Use bar's direction ?" )
dirtime      = input(2,"direction bars")

tema(sec, length)=>
    tema1= ema(sec, length)
    tema2= ema(tema1, length)
    tema3= ema(tema2, length)
    tema = 3*tema1-3*tema2+tema3

tema1 = tema(hlc3, tema_length_1)
tema2 = tema(hlc3, tema_length_2)

dir=if close/close[dirtime] > 1
    1
else
    -1

plot(tema1, color=color.green, transp=50)
plot(tema2, color=color.red, transp=50)


up =  crossover(tema1, tema2) 
down = crossunder(tema1, tema2)

long_condition =  up and (usedir ? dir==1 : true) and _testPeriod()
strategy.entry('BUY', strategy.long, when=long_condition)  
 
short_condition =  down
strategy.close('BUY', when=short_condition)