에일러스 인스턴트 트렌드 라인 전략

저자:차오장, 날짜: 2023-12-20 16:51:05
태그:

img

전반적인 설명

에일러스 즉각적인 트렌드 라인 전략은 존 에일러스가 그의 책?? 주식 및 선물에 대한 사이버네틱 분석?? 에서 제안했다. 이는 주식 / 선물의 실시간 트렌드를 식별하고 트렌드가 역전되면 오픈 포지션을 식별하기 위해 기술적 인 지표를 사용합니다.

전략 논리

이 전략의 핵심은 즉각적인 트렌드 라인 (IT) 을 계산하는 것입니다. IT의 공식은 다음과 같습니다.

it := (a-((a*a)/4.0))*src+0.5*a*a*src[1]-(a-0.75*a*a)*src[2]+2*(1-a )*it[1]-(1-a )*(1-a )*it[2]

src가 가격이고, a는 평형 인자이고, 기본값은 0.07입니다. 이 공식은 가격을 평형시키고 트렌드를 생성할 수 있는 2차 순위 필터입니다.

또 다른 핵심 지표는

lag = 2.0 * it - nz(it[2])

레이그 라인은 IT 라인을 1 바로 뒤쳐집니다. 가격이 레이그 라인을 넘으면 상승 브레이크를 신호합니다. 길게 가십시오. 가격이 레이그 라인을 넘으면 하락 브레이크를 신호합니다.

또한 전략은 위험을 통제하기 위해 스톱 로스 명령을 설정합니다.

이점 분석

이 전략의 장점은 다음과 같습니다.

  1. IT 라인은 노이즈를 효과적으로 필터링하고 신호 품질을 향상시킵니다.
  2. 2 차 순위 필터는 더 많은 조정 유연성과 견고성을 제공합니다
  3. 레이그 라인은 트렌드 내에서 불필요한 윙스를 피합니다.
  4. 포괄적 인 스톱 로스 컨트롤 위험은 미리 정의된 수준에서
  5. 깔끔한 코드 구조, 이해하기 쉽고 수정하기 쉬운

위험 분석

이 전략에는 몇 가지 위험도 있습니다.

  1. IT/Lag 라인의 잘못된 매개 변수 조정으로 인해 잘못된 신호가 발생할 수 있습니다.
  2. 잘못된 스톱 손실 구성으로 인해 조기 스톱 아웃 또는 과대 손실이 발생할 수 있습니다.
  3. 높은 거래 빈도는 누적 수수료로 이어집니다.
  4. 장시간 유지 시간이 손실 확대 위험을 증가시킵니다.

이러한 위험은 다음과 같이 완화 될 수 있습니다.

  1. 매개 변수 최적화를 위해 기계 학습을 적용
  2. 적응식 스톱 로스 레벨 설정
  3. 거래 빈도를 낮추기 위해 포지션 크기를 줄이는 것
  4. 소지 기간 중 손실을 중지하는 것을 포함합니다.

최적화 방향

이 전략은 다음과 같은 측면에서 더 이상 최적화 될 수 있습니다.

  1. 최적을 찾기 위해 다른 필터 매개 변수의 테스트 영향
  2. 신호를 필터링하기 위해 다른 지표를 결합 시도
  3. 트렌드 가속화 단계에서 크기를 높이기 위해 입구 논리를 개선
  4. 시장 변동성에 기초한 적응식 스톱 로스 설정
  5. 거래 세션 및 빈도에 대한 시간 시리즈 분석을 수행합니다.

결론

전체적으로, Ehlers Instantaneous Trendline 전략은 주식/미래 및 트렌드가 역전될 때 열린 포지션의 실시간 트렌드를 식별하기 위해 기술 지표를 활용합니다. 효과적인 노이즈 필터링, 높은 매개 변수 조정성, 명확한 신호 생성 논리 및 통합 위험 제어의 장점을 가지고 있습니다. 매개 변수 선택, 신호 필터링, 위치 사이즈링 및 스톱 로스 튜닝에 대한 추가 최적화로,이 전략은 더욱 나은 성능을 달성 할 수 있습니다. 명확한 코드 구조는 또한 이해하고 수정하는 것이 쉽습니다. 요약하자면, 이것은 테스트 및 개선 가치가있는 효율적인 트렌드 다음 시스템입니다.


/*backtest
start: 2022-12-13 00:00:00
end: 2023-12-19 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Ehlers Instantaneous Trendline Strategy", shorttitle = "Ehlers Instantaneous Trendline Strategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100.0, pyramiding = 1, backtest_fill_limits_assumption = 1)
src = input(hl2, title="Source")
a = input(0.07, title="Alpha", step=0.01) 
fr = input(false, title="Fill Trend Region")
it = na
if (na(it[2]) or na(it[1]))
    it := (src + 2 * src[1] + src[2]) / 4.0
else
    it := (a-((a*a)/4.0))*src+0.5*a*a*src[1]-(a-0.75*a*a)*src[2]+2*(1-a )*it[1]-(1-a )*(1-a )*it[2]
lag = 2.0 * it - nz(it[2])
rngFrac = input(0.35)
revPct = input(0.015)
stopType = input(title="Stop type", defval = "stop-order", options = ["stop-order", "market-order", "None"])

diff = input(0.5, title = "Spread")
LongPrice(p) =>
    LongPrice = diff == 0 ? p : floor(p / diff) * diff

ShortPrice(p) =>
    ShortPrice = diff == 0 ? p : ceil(p / diff) * diff

strategy.cancel_all()
reverseTrade = false
if stopType == "market-order" 
    if  strategy.position_size > 0 and close < strategy.position_avg_price * (1 - revPct) 
        strategy.order("StopLoss open short", strategy.short, 2 * strategy.position_size, limit = close - 2 * diff)
        reverseTrade := true
    if  strategy.position_size < 0 and close > strategy.position_avg_price * (1 + revPct) 
        strategy.order("StopLoss open long", strategy.long, -2 * strategy.position_size, limit = close + 2 * diff)
        reverseTrade := true
    
if lag > it and not reverseTrade
    price = LongPrice(max(close - (high - low) * rngFrac, low))
    if strategy.position_size <= 0
        strategy.order("Open long", strategy.long, strategy.equity / price - strategy.position_size, limit = price)
        if stopType == "stop-order"
            strategy.order("StopLoss open long", strategy.short, 2 * strategy.equity / price, stop = ShortPrice(price * (1 - revPct)))
    else
        if stopType == "stop-order"
            strategy.order("StopLoss open short", strategy.short, 2 * strategy.position_size, stop = ShortPrice(strategy.position_avg_price * (1 - revPct)))
if lag < it and not reverseTrade
    price = ShortPrice(min(close - (high - low) * rngFrac, high))
    if strategy.position_size >= 0
        strategy.order("Open short", strategy.short, strategy.equity / price + strategy.position_size, limit = price)
        if stopType == "stop-order"
            strategy.order("StopLoss open short", strategy.long, 2 * strategy.equity / price, stop = LongPrice(price * (1 + revPct)))
    else
        if stopType == "stop-order"
            strategy.order("StopLoss open long", strategy.long, -2 * strategy.position_size, stop = LongPrice(strategy.position_avg_price * (1 + revPct)))


itPlot=plot(it, color=red, linewidth=1, title="Trend")
lagPlot=plot(lag, color=blue, linewidth=1, title="Trigger")
fill(itPlot, lagPlot, it < lag ? green : red,  transp=70)

// === Backtesting Dates ===
testPeriodSwitch = input(false, "Custom Backtesting Dates")
testStartYear = input(2018, "Backtest Start Year")
testStartMonth = input(9, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testStartHour = input(0, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
testStopYear = input(2018, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(14, "Backtest Stop Day")
testStopHour = input(14, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
isPeriod = testPeriodSwitch == true ? testPeriod() : true
// === /END
if not isPeriod
    strategy.cancel_all()
    strategy.close_all()

더 많은