강화된 듀얼 피벗 포인트 반전 트레이딩 전략

ATR PP RSI SL TP RR
생성 날짜: 2024-12-05 15:06:15 마지막으로 수정됨: 2024-12-05 15:06:15
복사: 0 클릭수: 473
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

강화된 듀얼 피벗 포인트 반전 트레이딩 전략

개요

이 전략은 중심점 분석을 기반으로 한 고급 거래 시스템으로 시장의 중요한 전환점을 식별하여 잠재적인 트렌드 반전을 예측합니다. 이 전략은 혁신적인 “중심의 중심” 방식을 채택하고, 변동률 지표 ATR과 결합하여 포지션 관리를 수행하여 전체 거래 시스템을 형성합니다. 이 전략은 여러 시장에 적용되며, 다른 시장의 특성에 따라 파라미터를 최적화 할 수 있습니다.

전략 원칙

이 전략의 핵심은 두 계층의 축점 분석을 통해 시장 역전 기회를 식별하는 것입니다. 첫 번째 축점은 기본 높고 낮은 점이며, 두 번째 축점은 첫 번째 축점 중 선별한 눈에 띄는 전환점입니다. 가격이 이러한 중요한 수준을 돌파하면 시스템은 거래 신호를 냅니다. 동시에, 전략은 시장의 변동성을 측정하기 위해 ATR 지표를 사용하여 스톱 포지션 및 포지션 크기를 결정합니다.

전략적 이점

  1. 적응력: 전략은 다양한 시장 환경에 적응할 수 있으며, 변수를 조정하여 다양한 변동률 수준에 적응할 수 있다.
  2. 리스크 관리: ATR을 사용하여 동적 스톱 로드 설정을 수행하여 시장의 변동성에 따라 보호 조치를 자동으로 조정할 수 있습니다.
  3. 다단계 확인: 2단계 축점 분석으로 가짜 돌파의 위험을 줄입니다.
  4. 유연한 포지션 관리: 계정 규모와 시장의 변동성에 따라 포지션 크기를 조정한다.
  5. 명확한 입시 규칙: 명확한 신호 확인 메커니즘이 있어 주관적인 판단을 줄여줍니다.

전략적 위험

  1. 슬라이드 위험: 높은 변동성 시장에서 큰 슬라이드를 마주할 수 있다.
  2. 가짜 돌파 위험: 시장의 흔들림으로 인해 잘못된 신호가 발생할 수 있습니다.
  3. 과도한 레버리지 위험: 부적절한 레버리지 사용은 심각한 손실을 초래할 수 있습니다.
  4. 매개 변수 최적화 위험: 과도한 최적화는 과합으로 이어질 수 있다.

전략 최적화 방향

  1. 신호 필터: 트렌드 필터를 추가하여 주 트렌드 방향으로만 거래할 수 있습니다.
  2. 동적 변수: 시장 상태에 따라 중심축 점 변수를 자동으로 조정한다.
  3. 다중 시간 주기: 정확도를 높이기 위해 다중 시간 주기 확인을 추가하십시오.
  4. 지능형 상쇄: 상쇄를 추적하는 것과 같은 더 지능적인 상쇄 전략을 개발한다.
  5. 위험 관리: 연관성 분석과 같은 위험 관리 조치를 추가합니다.

요약하다

이것은 잘 설계된 트렌드 반전 거래 전략이며, 이중 축점 분석과 ATR 변동률 관리를 통해 안정적인 거래 시스템을 구축한다. 전략의 장점은 적응력이 강하고 위험 관리가 완벽하지만 여전히 거래자가 레버리지를 신중하게 사용하고 매개 변수를 지속적으로 최적화해야 한다는 것이다. 제안된 최적화 방향에 따라 전략은 향상될 여지가 있다. 이 전략은 안정적인 유형의 거래자가 사용할 수 있으며, 깊이 연구하고 실천할 가치가 있는 거래 시스템이다.

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

//@version=5
strategy("Pivot of Pivot Reversal Strategy [MAD]", shorttitle="PoP Reversal Strategy", overlay=true, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)

// Inputs with Tooltips
leftBars = input.int(4, minval=1, title='PP Left Bars', tooltip='Number of bars to the left of the pivot point. Increasing this value makes the pivot more significant.')
rightBars = input.int(2, minval=1, title='PP Right Bars', tooltip='Number of bars to the right of the pivot point. Increasing this value delays the pivot detection but may reduce false signals.')
atr_length = input.int(14, minval=1, title='ATR Length', tooltip='Length for ATR calculation. ATR is used to assess market volatility.')
atr_mult = input.float(0.1, minval=0.0, step=0.1, title='ATR Multiplier', tooltip='Multiplier applied to ATR for pivot significance. Higher values require greater price movement for pivots.')

allowLongs = input.bool(true, title='Allow Long Positions', tooltip='Enable or disable long positions.')
allowShorts = input.bool(true, title='Allow Short Positions', tooltip='Enable or disable short positions.')

margin_amount = input.float(1.0, minval=1.0, maxval=100.0, step=1.0, title='Margin Amount (Leverage)', tooltip='Set the leverage multiplier (e.g., 3x, 5x, 10x). Note: Adjust leverage in strategy properties for accurate results.')

risk_reward_enabled = input.bool(false, title='Enable Risk/Reward Ratio', tooltip='Enable or disable the use of a fixed risk/reward ratio for trades.')
risk_reward_ratio = input.float(1.0, minval=0.1, step=0.1, title='Risk/Reward Ratio', tooltip='Set the desired risk/reward ratio (e.g., 1.0 for 1:1).')
risk_percent = input.float(1.0, minval=0.1, step=0.1, title='Risk Percentage per Trade (%)', tooltip='Percentage of entry price to risk per trade.')

trail_stop_enabled = input.bool(false, title='Enable Trailing Stop Loss', tooltip='Enable or disable the trailing stop loss.')
trail_percent = input.float(0.5, minval=0.0, step=0.1, title='Trailing Stop Loss (%)', tooltip='Percentage for trailing stop loss.')

start_year  = input.int(2018, title='Start Year', tooltip='Backtest start year.')
start_month = input.int(1,    title='Start Month', tooltip='Backtest start month.')
start_day   = input.int(1,    title='Start Day',   tooltip='Backtest start day.')

end_year  = input.int(2100, title='End Year', tooltip='Backtest end year.')
end_month = input.int(1,    title='End Month', tooltip='Backtest end month.')
end_day   = input.int(1,    title='End Day',   tooltip='Backtest end day.')

date_start = timestamp(start_year, start_month, start_day, 00, 00)
date_end   = timestamp(end_year,   end_month,   end_day,   00, 00)
time_cond = time >= date_start and time <= date_end

// Pivot High Significant Function
pivotHighSig(left, right) =>
    pp_ok = true
    atr = ta.atr(atr_length)
    for i = 1 to left
        if high[right] < high[right + i] + atr * atr_mult
            pp_ok := false
    for i = 0 to right - 1
        if high[right] < high[i] + atr * atr_mult
            pp_ok := false
    pp_ok ? high[right] : na

// Pivot Low Significant Function
pivotLowSig(left, right) =>
    pp_ok = true
    atr = ta.atr(atr_length)
    for i = 1 to left
        if low[right] > low[right + i] - atr * atr_mult
            pp_ok := false
    for i = 0 to right - 1
        if low[right] > low[i] - atr * atr_mult
            pp_ok := false
    pp_ok ? low[right] : na

swh = pivotHighSig(leftBars, rightBars)
swl = pivotLowSig(leftBars, rightBars)

swh_cond = not na(swh)
var float hprice = 0.0
hprice := swh_cond ? swh : nz(hprice[1])

le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])

swl_cond = not na(swl)
var float lprice = 0.0
lprice := swl_cond ? swl : nz(lprice[1])

se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])

// Pivots of pivots
var float ph1 = 0.0
var float ph2 = 0.0
var float ph3 = 0.0
var float pl1 = 0.0
var float pl2 = 0.0
var float pl3 = 0.0
var float pphprice = 0.0
var float pplprice = 0.0

ph3 := swh_cond ? nz(ph2[1]) : nz(ph3[1])
ph2 := swh_cond ? nz(ph1[1]) : nz(ph2[1])
ph1 := swh_cond ? hprice     : nz(ph1[1])

pl3 := swl_cond ? nz(pl2[1]) : nz(pl3[1])
pl2 := swl_cond ? nz(pl1[1]) : nz(pl2[1])
pl1 := swl_cond ? lprice     : nz(pl1[1])

pphprice := swh_cond and ph2 > ph1 and ph2 > ph3 ? ph2 : nz(pphprice[1])
pplprice := swl_cond and pl2 < pl1 and pl2 < pl3 ? pl2 : nz(pplprice[1])

// Entry and Exit Logic
if time_cond
    // Calculate order quantity based on margin amount
    float order_qty = na
    if margin_amount > 0
        order_qty := (strategy.equity * margin_amount) / close

    // Long Position
    if allowLongs and le and not na(pphprice) and pphprice != 0
        float entry_price_long = pphprice + syminfo.mintick
        strategy.entry("PivRevLE", strategy.long, qty=order_qty, comment="PivRevLE", stop=entry_price_long)
        if risk_reward_enabled or (trail_stop_enabled and trail_percent > 0.0)
            float stop_loss_price = na
            float take_profit_price = na
            float trail_offset_long = na
            float trail_points_long = na
            if risk_reward_enabled
                float risk_amount = entry_price_long * (risk_percent / 100)
                stop_loss_price := entry_price_long - risk_amount
                float profit_target = risk_amount * risk_reward_ratio
                take_profit_price := entry_price_long + profit_target
            if trail_stop_enabled and trail_percent > 0.0
                trail_offset_long := (trail_percent / 100.0) * entry_price_long
                trail_points_long := trail_offset_long / syminfo.pointvalue
            strategy.exit("PivRevLE Exit", from_entry="PivRevLE",
                          stop=stop_loss_price, limit=take_profit_price,
                          trail_points=trail_points_long, trail_offset=trail_points_long)
    // Short Position
    if allowShorts and se and not na(pplprice) and pplprice != 0
        float entry_price_short = pplprice - syminfo.mintick
        strategy.entry("PivRevSE", strategy.short, qty=order_qty, comment="PivRevSE", stop=entry_price_short)
        if risk_reward_enabled or (trail_stop_enabled and trail_percent > 0.0)
            float stop_loss_price = na
            float take_profit_price = na
            float trail_offset_short = na
            float trail_points_short = na
            if risk_reward_enabled
                float risk_amount = entry_price_short * (risk_percent / 100)
                stop_loss_price := entry_price_short + risk_amount
                float profit_target = risk_amount * risk_reward_ratio
                take_profit_price := entry_price_short - profit_target
            if trail_stop_enabled and trail_percent > 0.0
                trail_offset_short := (trail_percent / 100.0) * entry_price_short
                trail_points_short := trail_offset_short / syminfo.pointvalue
            strategy.exit("PivRevSE Exit", from_entry="PivRevSE",
                          stop=stop_loss_price, limit=take_profit_price,
                          trail_points=trail_points_short, trail_offset=trail_points_short)

// Plotting
plot(lprice, color=color.new(color.red, 55), title='Low Price')
plot(hprice, color=color.new(color.green, 55), title='High Price')
plot(pplprice, color=color.new(color.red, 0), linewidth=2, title='Pivot Low Price')
plot(pphprice, color=color.new(color.green, 0), linewidth=2, title='Pivot High Price')