다중 지표를 기반으로 한 추세 추종 전략


생성 날짜: 2023-12-27 17:15:45 마지막으로 수정됨: 2023-12-27 17:15:45
복사: 1 클릭수: 599
avatar of ChaoZhang ChaoZhang
1
집중하다
1623
수행원

다중 지표를 기반으로 한 추세 추종 전략

개요

이 정책은다중 지표 조합 트렌드 추적 전략(Multi-Indicator Trend Tracking Strategy) 는 피셔 변동 지표, 중도 이동 평균 (WMA), 상대적으로 강한 지표 (RSI) 및 평균선 (OBV) 과 같은 여러 지표를 사용하여 시장 추세 방향을 판단하여 트렌드 추적 거래를 수행한다.

전략 원칙

  1. 피셔 변환 지표는 가격 변화의 경향과 강도를 판단한다. 4개의 피셔 라인이 동시에 변할 때 거래 신호를 낸다.
  2. WMA는 큰 트렌드 방향을 판단한다. RSI는 가짜 신호를 필터링한다.
  3. OBV 지표는 트렌드를 확인하는 데 사용됩니다.

구체적으로, 피셔 변환 지표는 1배, 2배, 4배 및 8배 4개의 라인을 포함한다. 4개의 라인이 동시에 위쪽으로 초록색으로 올라갈 때 다중 신호를 생성하고, 4개의 라인이 동시에 아래쪽으로 빨간색으로 올라갈 때 공백 신호를 생성한다. WMA는 큰 트렌드 방향을 판단하고, 지표가 위쪽으로 올라간다면 낙관적이라고 판단하고, 하향으로 내려간다면 낙관적이라고 판단한다. OBV는 트렌드 방향을 확인하는 데 사용됩니다. 상대적으로 강한 지표 RSI는 가짜 신호를 필터링한다.

우위 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 피셔 변환 지표의 판단력이 강하여 4개의 피셔 라인이 동시에 변하면 트렌드가 반전될 가능성이 높다.
  2. WMA는 주요 트렌드 방향을 판단하여 역동적인 거래를 피한다.
  3. OBV 지표는 트렌드를 확인하고, 트렌드리스 시장의 가짜 돌파구를 피한다.
  4. RSI 지표는 가짜 신호를 필터링하여 신호의 신뢰성을 보장한다.

여러 지표의 조합을 통해 거래 신호의 정확성과 신뢰성을 보장하고, 트렌드를 추적할 수 있는 능력으로 더 나은 전략 효과를 얻을 수 있다.

위험 분석

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

  1. 시장이 평형되면, 피셔 라인은 가짜 신호를 발생시킬 수 있다. 이 경우 RSI 필터링에 의존한다.
  2. WMA 변수 설정이 잘못되면 판단 accurancy에 영향을 미칩니다.
  3. 피셔 변환 지표는 초단계 행태에 대한 판단이 나빴다.
  4. 이 전략은 전선을 가로막으면 엄청난 손실을 초래할 수 있다.

위험을 줄이기 위해 RSI 파라미터를 적절히 조정할 수 있으며, WMA 주기 파라미터를 최적화할 수 있다. 또한, 막상 손실을 방지하기 위해 스톱포드를 설정할 수 있다.

최적화 방향

이 전략은 다음과 같은 부분에서 더욱 개선될 수 있습니다.

  1. 다양한 주기 변수 아래의 전략 효과를 테스트할 수 있으며, 최적의 변수 조합을 찾을 수 있다.
  2. 손해 중지 메커니즘을 추가한다. 손실이 일정 비율에 도달했을 때 중지한다.
  3. 피셔 변환 지표의 파라미터를 재측량 결과에 따라 더 조정하여 지표를 판단하는 가장 정확한 파라미터 조합을 찾습니다.
  4. 다른 지표 필터를 추가해 보세요. 강점, 약점, 편견 등등.
  5. 다양한 포지션 크기를 테스트하십시오.

요약하다

이 전략은 피셔 변동 지표, WMA 지표, OBV 지표 및 RSI 지표를 종합적으로 사용하여 시장의 경향 방향을 판단한다. 판단 신호는 정확하고, 확인 능력이 강하며, 트렌드를 효과적으로 고정하여 이익을 얻을 수 있다. 매개 변수를 최적화하면 전략의 수익 인자를 더욱 향상시킬 수 있다.

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

//@version=5
//author Sdover0123
strategy(title='FTR, WMA, OBV & RSI Strat', shorttitle='FTR WMA, OBV, RSI',overlay=false, default_qty_type=strategy.percent_of_equity, initial_capital = 100, default_qty_value=100, commission_value = 0.06, pyramiding = 3)
Len = input.int(10, minval=1, group ="Fisher Transform")
mult1 = input.int(1, minval=1, group ="Fisher Transform")
mult2 = input.int(2, minval=1, group ="Fisher Transform")
mult3 = input.int(4, minval=1, group ="Fisher Transform")
mult4 = input.int(8, minval=1, group ="Fisher Transform")
fish(Length, timeMultiplier) =>
    var nValue1 = 0.0
    var nValue2 = 0.0
    var nFish = 0.0
    xHL2 = hl2
    xMaxH = ta.highest(xHL2, Length * timeMultiplier)
    xMinL = ta.lowest(xHL2, Length * timeMultiplier)
    nValue1 := 0.33 * 2 * ((xHL2 - xMinL) / (xMaxH - xMinL) - 0.5) + 0.67 * nz(nValue1[1])
    if nValue1 > .99
        nValue2 := .999
        nValue2
    else if nValue1 < -.99
        nValue2 := -.999
        nValue2
    else
        nValue2 := nValue1
        nValue2
    nFish := 0.5 * math.log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
    nFish
Fisher1 = fish(Len, mult1)
Fisher2 = fish(Len, mult2)
Fisher4 = fish(Len, mult3)
Fisher8 = fish(Len, mult4)

rsiLength = input.int(14, minval=1, group ="Moving Averages")
rsiVal = (ta.rsi(close, rsiLength) - 50) / 10
avg = strategy.position_avg_price

wma(source, length) =>
    sum = 0.0
    for i = 0 to length - 1
        sum := sum + source[i] * (length - i)
    wma = sum / (length * (length + 1) / 2)
    wma

wmaLength = input.int(10, "WMA Length", minval=1, group ="Moving Averages")
wmaClose = wma(close, wmaLength)
// Determine if WMA is bullish or bearish
isWmaBullish = wmaClose > wmaClose[1]
isWmaBearish = wmaClose < wmaClose[1]

//OBV 
src = close
length = input.int(20, title="OBV Length", group="On-Balance Volume")
obv1(src) =>
    change_1 = ta.change(src)
    ta.cum(ta.change(src) > 0 ? volume : change_1 < 0 ? -volume : 0 * volume)*0.01
os = obv1(src)
obv_osc = os - ta.ema(os, length)
obc_color = (obv_osc > 0 ? color.rgb(0, 255, 8) : color.rgb(255, 0, 0))
plot(obv_osc, color=obc_color, style=plot.style_line, title='OBV-Points', linewidth=2)
plot(obv_osc, color=color.new(#b2b5be, 70), title='OBV', style=plot.style_area)
obvBullFilter = input.float(0.1, minval = 0, maxval = 5, step = 0.01, title ="OBV Bullish minimum value", group="On-Balance Volume")
obvBearFilter = input.float(-0.1, minval = -5, maxval = 0, step = 0.01, title ="OBV Bearish minimum value", group="On-Balance Volume")
obvBull = obv_osc > obvBullFilter
obvBear = obv_osc < obvBearFilter

// Add buy/sell signals
ReversalFilterDown = input.float(-0.7, 'Reversal Down TP Filter', -4, 4, step = 0.01, group = "RSI Level Filters", tooltip = "This is defined by taking the RSI value -50 and /10. When all Fisher lines are changing colour, this will SL/TP the long")
ReversalFilterUp = input.float(0.7, 'Reversal Up TP Filter', -4, 4, step = 0.01, group = "RSI Level Filters", tooltip = "This is defined by taking the RSI value -50 and /10. When all Fisher lines are changing colour, this will SL/TP the short")
RSILevelBuyFilter = input.float(1.66, 'RSI Level Buy Filter', -4, 4, step = 0.01, group = "RSI Level Filters", tooltip = "This is defined by taking the RSI value -50 and /10. Consider negative values")
RSILevelSellFilter = input.float(1, 'RSI Level Sell Filter', -4, 4, step = 0.01, group = "RSI Level Filters", tooltip = "This is defined by taking the RSI value -50 and /10. Consider negative values")
//buys - if breaking out and all Fisher are green and RSI filter value is met 
buySignal = Fisher1 > Fisher1[1] and Fisher2 > Fisher2[1] and Fisher4 > Fisher4[1] and Fisher8 > Fisher8[1] and rsiVal > RSILevelBuyFilter and isWmaBullish and obvBull
ReversalUp = Fisher1 > Fisher1[1] and Fisher2 > Fisher2[1] and Fisher4 > Fisher4[1] and Fisher8 > Fisher8[1] and rsiVal > ReversalFilterUp
//sells - if breaking down and all Fisher are green and RSI filter value is met 
sellSignal = Fisher1 < Fisher1[1] and Fisher2 < Fisher2[1] and Fisher4 < Fisher4[1] and Fisher8 < Fisher8[1] and rsiVal < RSILevelSellFilter and isWmaBearish and obvBear
ReversalDown = Fisher1 < Fisher1[1] and Fisher2 < Fisher2[1] and Fisher4 < Fisher4[1] and Fisher8 < Fisher8[1] and rsiVal < ReversalFilterDown


// Buy and Sell conditions
if buySignal and time>timestamp(2022, 06, 01, 09, 30) and barstate.isconfirmed
    strategy.close("Sell", comment = "Close Short")
    strategy.entry("Buy", strategy.long, comment = "Long")

if sellSignal and time>timestamp(2022, 06, 01, 09, 30) and barstate.isconfirmed
    strategy.close("Buy", comment = "Close Long")
    strategy.entry("Sell", strategy.short, comment = "Short")

if ReversalDown
    strategy.close("Buy", comment = "Close Long")

if ReversalUp
    strategy.close("Sell", comment = "Close Short")

//Plotting
//Fisher
plot(Fisher1, color=Fisher1 > nz(Fisher1[1]) ? color.green : color.rgb(255, 0, 0), title='Fisher TF:1')
plot(Fisher2, color=Fisher2 > nz(Fisher2[1]) ? color.green : color.rgb(255, 0, 0), title='Fisher TF:1', linewidth=2)
plot(Fisher4, color=Fisher4 > nz(Fisher4[1]) ? #008000 : #b60000, title='Fisher TF:1', linewidth=3)
plot(Fisher8, color=Fisher8 > nz(Fisher8[1]) ? #004f00 : #b60000, title='Fisher TF:1', linewidth=3)
//RSI
plot(rsiVal, color=rsiVal < 0 ? color.purple : color.yellow, linewidth=2, title='RSI')

//WMA
plot(isWmaBullish ? -2 : na, color=color.rgb(76, 175, 79, 20), linewidth=3, style=plot.style_linebr, title="WMA Bullish")
plot(isWmaBearish ? -2 : na, color=color.rgb(255, 82, 82, 20), linewidth=3, style=plot.style_linebr, title="WMA Bearish")

//Buy/Sell Signals
plotshape(buySignal, title='Buy Signal', location=location.bottom, color=color.new(color.lime, 0), style=shape.triangleup, size=size.small)
plotshape(sellSignal, title='Sell Signal', location=location.top, color=color.new(color.red, 0), style=shape.triangledown, size=size.small)

//Orientation
hline(RSILevelBuyFilter, color=color.rgb(25, 36, 99, 20), linestyle=hline.style_dotted, linewidth=2)
hline(RSILevelSellFilter, color=color.rgb(111, 27, 27, 20), linestyle=hline.style_dotted, linewidth=2)
hline(0, color=color.rgb(181, 166, 144, 39), linestyle=hline.style_dashed, linewidth=2, title = "Zero Line")
hline(1.5, color=color.rgb(217, 219, 220, 50), linestyle=hline.style_dotted, linewidth=2, title = "1.5 // 65 Line")
hline(-1.5, color=color.rgb(217, 219, 220, 50), linestyle=hline.style_dotted, linewidth=2, title = "-1.5 // 35 Line")