피보나치 리트레이싱 기반의 자동 트렌드

저자:차오장, 날짜: 2024-01-05 11:34:17
태그:

img

전반적인 설명

이 전략은 피보나치 리트레이스먼트 비율을 기반으로 주식 가격의 ABC 패턴을 자동으로 식별하고 긴/단 신호를 생성합니다. 가격 파도를 결정하고 ABC 파도 사이의 피보나치 리트레이스먼트 비율을 계산하기 위해 피보나치 포인트를 사용합니다. 비율이 특정 기준을 충족하면 거래 신호가 생성됩니다.

전략 논리

  1. 주식 주축의 높고 낮은 지점을 계산합니다.
  2. 가격이 이전 높은 지점에서 떨어졌는지 또는 이전 낮은 지점에서 상승했는지 판단합니다.
  3. 현재 물결과 이전 물결 사이의 피보나치 회귀 비율을 계산합니다.
  4. 위와 아래 파도의 복귀 비율이 적절한 범위 내에 있다면, 잠재적 ABC 패턴을 결정
  5. ABC 패턴 확인 후, 점 C에 Stop Loss을 설정합니다.

이점 분석

  1. 피워트 포인트는 신호 정확성을 향상시키기 위해 주요 지원/저항 수준을 식별합니다.
  2. 피보나치 리트레이스는 ABC 패턴을 식별함으로써 트렌드 전환점을 잡습니다.
  3. 명확한 이익/손실 규칙으로 막대한 손실을 피할 수 있습니다

위험 분석

  1. 피보나치 리트레이싱과 피보나치 피보나치 리트레이싱은 모든 트렌드 전환점을 완벽하게 식별할 수 없습니다. 잘못된 판단이 발생할 수 있습니다.
  2. 점 C와 점 A가 멈출 때, 더 큰 손실로 이어질 수 있습니다.
  3. 피보나치 리트레이싱 비율 범위와 같은 매개 변수는 추가 최적화가 필요합니다.

최적화 방향

  1. ABC 패턴 확인을 돕기 위해 더 많은 기술 지표를 통합하여 신호 정확도를 향상시킵니다.
  2. 더 많은 시장 조건에 맞게 피보나치 리트레이싱 비율 범위를 최적화하십시오.
  3. 기계 학습 방법을 사용하여 ABC 패턴 인식 모델을 훈련하십시오.

결론

이 전략은 트렌드 전환점에 긴/단순 신호를 생성하기 위한 ABC 패턴을 식별하고, 주요 지지/저항 수준의 피보트 포인트 확인과 피보나치 리트레이싱 비율 계산을 기반으로 한다. 논리는 간단하고 깨끗하며, 위험을 효과적으로 제어하는 합리적인 이익/손실 규칙이 있다. 그러나 일부 잘못된 판단 위험이 남아 있어 더 많은 시장 조건에 맞게 추가 최적화와 개선이 필요하다.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-19 23:59:59
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

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

//@version=5
strategy("ABCD Strategy", shorttitle="ABCDS", overlay=true, commission_value=0.04)
calcdev(fprice, lprice, fbars, lbars) =>
    rise = lprice - fprice
    run = lbars - fbars
    avg = rise/run
    ((bar_index - lbars) * avg) + lprice

len = input(5)

ph = ta.pivothigh(len, len)
pl = ta.pivotlow(len, len)

var bool ishigh = false
ishigh := ishigh[1]

var float currph = 0.0
var int currphb = 0
currph := nz(currph)
currphb := nz(currphb)

var float oldph = 0.0
var int oldphb = 0
oldph := nz(oldph)
oldphb := nz(oldphb)

var float currpl = 0.0
var int currplb = 0
currpl := nz(currpl)
currplb := nz(currplb)

var float oldpl = 0.0
var int oldplb = 0
oldpl := nz(oldpl)
oldplb := nz(oldplb)

if (not na(ph))
    ishigh := true
    oldph := currph
    oldphb := currphb
    currph := ph
    currphb := bar_index[len]
else
    if (not na(pl))
        ishigh := false
        oldpl := currpl
        oldplb := currplb
        currpl := pl
        currplb := bar_index[len]

endHighPoint = calcdev(oldph, currph, oldphb, currphb)
endLowPoint = calcdev(oldpl, currpl, oldplb, currplb)

plotshape(ph, style=shape.triangledown, color=color.red, location=location.abovebar, offset=-len)
plotshape(pl, style=shape.triangleup, color=color.green, location=location.belowbar, offset=-len)

// var line lnhigher = na
// var line lnlower = na
// lnhigher := line.new(oldphb, oldph, bar_index, endHighPoint)
// lnlower := line.new(oldplb, oldpl, bar_index, endLowPoint)
// line.delete(lnhigher[1])
// line.delete(lnlower[1])

formlong = oldphb < oldplb and oldpl < currphb and currphb < currplb
longratio1 = (currph - oldpl) / (oldph - oldpl)
longratio2 = (currph - currpl) / (currph - oldpl)

formshort = oldplb < oldphb and oldphb < currplb and currplb < currphb
shortratio1 = (oldph - currpl) / (oldph - oldpl)
shortratio2 = (currph - currpl) / (oldph - currpl)

// prevent multiple entry for one pattern
var int signalid = 0
signalid := nz(signalid[1])

longCond = formlong and 
           longratio1 < 0.7 and 
           longratio1 > 0.5 and 
           longratio2 > 1.1 and 
           longratio2 < 1.35 and 
           close < oldph and 
           close > currpl and 
           signalid != oldplb
if (longCond)
    signalid := oldplb
    longsl = currpl - ta.tr
    longtp = ((close - longsl) * 1.5) + close
    strategy.entry("Long", strategy.long)
    strategy.exit("Exit Long", "Long", limit=math.min(longtp, oldph), stop=longsl)

shortCond = formshort and 
             shortratio1 < 0.7 and 
             shortratio1 > 0.5 and 
             shortratio2 > 1.1 and 
             shortratio2 < 1.35 and 
             close > oldpl and 
             close < currph and 
             signalid != oldphb

if (shortCond)
    signalid := oldphb
    shortsl = currph + ta.tr
    shorttp = close - ((shortsl - close) * 1.5)
    strategy.entry("Short", strategy.short)
    strategy.exit("Exit Short", "Short", limit=math.max(shorttp, oldpl), stop=shortsl)


더 많은