PPO 가격 감수성 모멘텀 이중 하위 방향 거래 전략

저자:차오장날짜: 2024-01-29 11:38:42
태그:

img

전반적인 설명

PPO 가격 감수성 모멘텀 이중 바닥 방향 거래 전략은 PPO (퍼센트 가격 오시레이터) 지표에 의해 가격 이중 바닥 형식의 식별을 활용하여 거래 신호를 생성하는 트렌드 다음 거래 전략이다. 이중 바닥 패턴 인식과 가격 모멘텀 특성을 결합하여 가격 이중 바닥 반전 지점을 정확하게 위치시킵니다.

전략 원칙

이 전략은 PPO 지표를 사용하여 가격 이중 바닥 특징을 결정하며, PPO 지표의 바닥 형성을 실시간으로 모니터링하기 위해 가격 최소 포인트 판단을 통합합니다. PPO가 상승 역전 이중 바닥을 형성하면 현재 구매 기회를 신호합니다.

한편, 전략은 가격 최소 가치 결정과 협력하여 가격이 상대적으로 낮은 수준에 있는지 확인합니다. PPO가 바닥 패턴을 표시하는 동안 가격이 낮게 유지되면 구매 신호가 유발됩니다.

PPO 역전 특성 검증과 가격 수준 확인 이중 메커니즘을 통해 잠재적인 가격 역전 가능성을 효과적으로 식별하여 잘못된 신호를 필터링하고 신호 품질을 향상시킬 수 있습니다.

이점 분석

  1. PPO의 이중 바닥 패턴은 입구점에서의 정확한 타이밍을 가능하게 합니다.

  2. 가격 레벨 확인을 결합하면 상대적으로 높은 수준에서 발생하는 잘못된 신호를 필터링하여 신호 품질을 향상시킵니다.

  3. PPO는 민감하고 가격 트렌드 변화를 빠르게 파악하여 트렌드 추적에 적합합니다.

  4. 이중 확인 메커니즘은 거래 위험을 효과적으로 완화합니다.

위험 과 해결책

  1. PPO는 다른 지표로부터 확인을 요구하는 잘못된 신호를 생성하는 경향이 있습니다. 이동 평균 또는 변동성 지표는 확인에 도움이 될 수 있습니다.

  2. 이중 하위 반전은 지속되지 않을 수 있으며, 추가 하락의 위험에 직면 할 수 있습니다. 포지션 사이징 최적화와 함께 스톱 로스를 설정할 수 있습니다.

  3. 부적절한 매개 변수 구성으로 인해 손실 된 이익 또는 잘못된 항목이 발생합니다. 매개 변수 조합에 대한 반복된 백테스트 및 최적화가 필요합니다.

  4. 복제와 함께 상당한 코드 볼륨이 있습니다. 추가 모듈화는 중복된 코드를 줄이는 데 도움이됩니다.

최적화 방향

  1. 스톱 로스 모듈을 통합하고 포지션 사이징 전략을 최적화합니다.

  2. 이동 평균 또는 변동성 지표를 확인 도구로 도입합니다.

  3. 부하적인 논리 판단을 피하기 위해 코드를 모듈화합니다.

  4. 안정성을 높이기 위해 매개 변수를 계속 조정하세요.

  5. 더 많은 제품에서 스프레드 트레이딩 애플리케이션을 테스트합니다.

결론

PPO 가격 감수성 모멘텀 이중 하단 방향 거래 전략은 PPO 지표의 이중 하단 특징과 함께 가격 레벨 위치의 이중 확인을 통해 가격 반전 지점을 효과적으로 파악합니다. 단일 지표 판단에 비해 정확성과 소음을 필터링하는 능력이 향상된 장점이 있습니다. 그럼에도 불구하고 잘못된 신호의 특정 위험이 남아 있으며 라이브 거래에서 안정적인 수익성을 달성하기 전에 지표 조합 및 엄격한 위치 사이징 전술에 대한 추가 최적화가 필요합니다.


/*backtest
start: 2024-01-27 00:00:00
end: 2024-01-28 00:00:00
period: 2h
basePeriod: 15m
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/
// © luciancapdefier

//@version=4
strategy("PPO Divergence ST", overlay=true, initial_capital=30000, calc_on_order_fills=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// time
FromYear = input(2019, "Backtest Start Year")
FromMonth = input(1, "Backtest Start Month")
FromDay = input(1, "Backtest Start Day")
ToYear = input(2999, "Backtest End Year")
ToMonth = input(1, "Backtest End Month")
ToDay = input(1, "Backtest End Day")
start = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window() => time >= start and time <= finish ? true : false 

source = close
topbots = input(true, title="Show PPO high/low triangles?")
long_term_div = input(true, title="Use long term divergences?")
div_lookback_period = input(55, minval=1, title="Lookback Period")
fastLength = input(12, minval=1, title="PPO Fast")
slowLength=input(26, minval=1, title="PPO Slow")
signalLength=input(9,minval=1, title="PPO Signal")
smoother = input(2,minval=1, title="PPO Smooth")
fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)
macd = fastMA - slowMA
macd2=(macd/slowMA)*100
d = sma(macd2, smoother) // smoothing PPO
 
bullishPrice = low 

priceMins = bullishPrice > bullishPrice[1] and bullishPrice[1] < bullishPrice[2] or low[1] == low[2] and low[1] < low and low[1] < low[3] or low[1] == low[2] and low[1] == low[3] and low[1] < low and low[1] < low[4] or low[1] == low[2] and low[1] == low[3] and low[1] and low[1] == low[4] and low[1] < low and low[1] < low[5] // this line identifies bottoms and plateaus in the price
oscMins= d > d[1] and d[1] < d[2] // this line identifies bottoms in the PPO

BottomPointsInPPO = oscMins

bearishPrice = high
priceMax = bearishPrice < bearishPrice[1] and bearishPrice[1] > bearishPrice[2] or high[1] == high[2] and high[1] > high and high[1] > high[3] or high[1] == high[2] and high[1] == high[3] and high[1] > high and high[1] > high[4] or high[1] == high[2] and high[1] == high[3] and high[1] and high[1] == high[4] and high[1] > high and high[1] > high[5]  // this line identifies tops in the price
oscMax = d < d[1] and d[1] > d[2]   // this line identifies tops in the PPO

TopPointsInPPO = oscMax

currenttrough4=valuewhen (oscMins, d[1], 0) // identifies the value of PPO at the most recent BOTTOM in the PPO
lasttrough4=valuewhen (oscMins, d[1], 1) // NOT USED identifies the value of PPO at the second most recent BOTTOM in the PPO
currenttrough5=valuewhen (oscMax, d[1], 0) // identifies the value of PPO at the most recent TOP in the PPO
lasttrough5=valuewhen (oscMax, d[1], 1) // NOT USED identifies the value of PPO at the second most recent TOP in the PPO

currenttrough6=valuewhen (priceMins, low[1], 0) // this line identifies the low (price) at the most recent bottom in the Price
lasttrough6=valuewhen (priceMins, low[1], 1) // NOT USED this line identifies the low (price) at the second most recent bottom in the Price
currenttrough7=valuewhen (priceMax, high[1], 0) // this line identifies the high (price) at the most recent top in the Price
lasttrough7=valuewhen (priceMax, high[1], 1) // NOT USED this line identifies the high (price) at the second most recent top in the Price

delayedlow = priceMins and barssince(oscMins) < 3 ? low[1] : na
delayedhigh = priceMax and barssince(oscMax) < 3 ? high[1] : na

// only take tops/bottoms in price when tops/bottoms are less than 5 bars away
filter = barssince(priceMins) < 5 ? lowest(currenttrough6, 4) : na
filter2 = barssince(priceMax) < 5 ? highest(currenttrough7, 4) : na

//delayedbottom/top when oscillator bottom/top is earlier than price bottom/top
y11 = valuewhen(oscMins, delayedlow, 0)
y12 = valuewhen(oscMax, delayedhigh, 0)

// only take tops/bottoms in price when tops/bottoms are less than 5 bars away, since 2nd most recent top/bottom in osc
y2=valuewhen(oscMax, filter2, 1) // identifies the highest high in the tops of price with 5 bar lookback period SINCE the SECOND most recent top in PPO
y6=valuewhen(oscMins, filter, 1) // identifies the lowest low in the bottoms of price with 5 bar lookback period SINCE the SECOND most recent bottom in PPO

long_term_bull_filt = valuewhen(priceMins, lowest(div_lookback_period), 1)
long_term_bear_filt = valuewhen(priceMax, highest(div_lookback_period), 1)

y3=valuewhen(oscMax, currenttrough5, 0) // identifies the value of PPO in the most recent top of PPO 
y4=valuewhen(oscMax, currenttrough5, 1) // identifies the value of PPO in the second most recent top of PPO 

y7=valuewhen(oscMins, currenttrough4, 0) // identifies the value of PPO in the most recent bottom of PPO
y8=valuewhen(oscMins, currenttrough4, 1) // identifies the value of PPO in the SECOND most recent bottom of PPO

y9=valuewhen(oscMins, currenttrough6, 0)
y10=valuewhen(oscMax, currenttrough7, 0)

bulldiv= BottomPointsInPPO ? d[1] : na // plots dots at bottoms in the PPO
beardiv= TopPointsInPPO ? d[1]: na // plots dots at tops in the PPO

i = currenttrough5 < highest(d, div_lookback_period) // long term bearish oscilator divergence
i2 = y10 > long_term_bear_filt // long term bearish top divergence
i3 = delayedhigh > long_term_bear_filt // long term bearish delayedhigh divergence

i4 = currenttrough4 > lowest(d, div_lookback_period) // long term bullish osc divergence
i5 = y9 < long_term_bull_filt // long term bullish bottom div
i6 = delayedlow < long_term_bull_filt // long term bullish delayedbottom div

//plot(0, color=gray)
//plot(d, color=black)
//plot(bulldiv, title = "Bottoms", color=maroon, style=circles, linewidth=3, offset= -1)
//plot(beardiv, title = "Tops", color=green, style=circles, linewidth=3, offset= -1)

bearishdiv1 = (y10 > y2 and oscMax and y3 < y4) ? true : false
bearishdiv2 = (delayedhigh > y2 and y3 < y4) ? true : false
bearishdiv3 = (long_term_div and oscMax and i and i2) ? true : false
bearishdiv4 = (long_term_div and i and i3) ? true : false

bullishdiv1 = (y9 < y6 and oscMins and y7 > y8) ? true : false
bullishdiv2 = (delayedlow < y6 and y7 > y8) ? true : false
bullishdiv3 = (long_term_div and oscMins and i4 and i5) ? true : false
bullishdiv4 = (long_term_div and i4 and i6) ? true : false

bearish = bearishdiv1 or bearishdiv2 or bearishdiv3 or bearishdiv4
bullish = bullishdiv1 or bullishdiv2 or bullishdiv3 or bullishdiv4
 
greendot = beardiv != 0 ? true : false
reddot = bulldiv != 0 ? true : false

if (reddot and window())
    strategy.entry("Buy Id", strategy.long, comment="BUY")

if (greendot and window())
    strategy.entry("Sell Id", strategy.short, comment="SELL")

alertcondition( bearish, title="Bearish Signal (Orange)", message="Orange & Bearish: Short " ) 
alertcondition( bullish, title="Bullish Signal (Purple)", message="Purple & Bullish: Long " )
alertcondition( greendot, title="PPO High (Green)", message="Green High Point: Short " ) 
alertcondition( reddot, title="PPO Low (Red)", message="Red Low Point: Long " )

// plotshape(bearish ? d : na, text='▼\nP', style=shape.labeldown, location=location.abovebar, color=color(orange,0), textcolor=color(white,0), offset=0)
// plotshape(bullish ? d : na, text='P\n▲', style=shape.labelup, location=location.belowbar, color=color(#C752FF,0), textcolor=color(white,0), offset=0)
plotshape(topbots and greendot ? d : na, text='', style=shape.triangledown, location=location.abovebar, color=color.red, offset=0, size=size.tiny)
plotshape(topbots and reddot ? d : na, text='', style=shape.triangleup, location=location.belowbar, color=color.lime, offset=0, size=size.tiny)

//barcolor(bearishdiv1 or bearishdiv2 or bearishdiv3 or bearishdiv4 ? orange : na)
//barcolor(bullishdiv1 or bullishdiv2 or bullishdiv3 or bullishdiv4 ? fuchsia : na)
//barcolor(#dedcdc)

    
    
    
    

더 많은