피어싱 핀 바 역전 전략

저자:차오장, 날짜: 2024-01-25 12:29:29
태그:

img

전반적인 설명

피어싱 핀 바 반전 전략은 단기 가격 패턴에 기반한 트렌드 거래 전략이다. 트렌드 방향을 결정하기 위해 이동 평균과 결합하여 신호로 핀 바를 활용하여 고정도 입력을 달성합니다. 또한 매우 높은 수익성을 실현하기 위해 독특한 트레일링 스톱 메커니즘을 사용합니다.

원칙

입력 신호

이 전략의 입력 신호는 핀 바를 뚫는 것입니다. 구체적으로 신호는 다음과 같이 발생하면 발사됩니다.

  1. 특정 단기 패턴이 형성됩니다: 상승 핀 바에서 상승 신호, 하락 핀 바에서 하락 신호

이러한 조합은 대부분의 소음을 필터링하고 입력 정밀도를 높입니다.

트렌드 정의

손실 중지 메커니즘

이점 분석

높은 효율성

극히 큰 이익 취

독특한 트레일링 스톱은 이 전략의 가장 큰 하이라이트입니다. 최대 포착 수익을 보장하면서 거래 기준으로 작은 범위 내에서 정밀하게 스톱 손실을 제어합니다.

위험 분석

과도한 체력 위험

또한, 짧은 2년 시험 기간은 실제 결과에 영향을 줄 수 있는 구조적 시장 체제 변화를 포착하지 않을 수 있습니다.

후속 중지 위험

지나치게 민감한 트레일링 스톱 값은 과도한 원치 않는 스톱 아웃을 유발할 수 있습니다. 갑작스러운 시장 이벤트는 트레일링 스톱 손실 주문을 무효화 할 수도 있습니다. 이것은 트레일링 스톱을 사용하는 것과 관련된 본질적인 위험입니다.

최적화 방향

후속 중지 매개 변수를 조정합니다

후속 스톱은 미친 수익성의 열쇠입니다. 민첩하고 신뢰할 수 있도록 하려면, 과민성을 피하기 위해 후속 스톱을 느슨하게 시도하십시오.

테스트 기간을 늘리는 것도 매개 변수 안정성을 조사하는 데 도움이 됩니다.

MA 기간을 최적화

현재 MA 기간은 최적의 매개 변수 세트가 아닐 가능성이 있습니다. 추가 최적화는 더 나은 성능을 위해 더 나은 값을 발견 할 수 있습니다.

예를 들어, 빠른 기간과 중간 기간 사이의 차이를 증가시키거나, MA가 상호 작용하는 방식을 수정하는 것.

결론

적절한 매개 변수 조정 또는 최적화와 함께, 이 전략은 라이브 거래에서 상당한 수익을 창출할 수 있으며, 강력한 트렌드 추적 시스템으로 자리 잡을 수 있습니다. 독특한 트레일링 스톱 개념은 또한 더 혁신적인 전략으로 이어질 수 있는 귀중한 영감을 제공합니다.


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

//@version=4
//Time Frame: H1
strategy("Pin Bar Magic v1", overlay=true)

// User Input
usr_risk = input(title="Equity Risk (%)",type=input.integer,minval=1,maxval=100,step=1,defval=3,confirm=false)
atr_mult = input(title="Stop Loss (x*ATR, Float)",type=input.float,minval=0.1,maxval=100,step=0.1,defval=0.5,confirm=false)
slPoints = input(title="Stop Loss Trail Points (Pips)",type=input.integer,minval=1,maxval=1000,step=1,defval=1,confirm=false)
slOffset = input(title="Stop Loss Trail Offset (Pips)",type=input.integer,minval=1,maxval=1000,step=1,defval=1,confirm=false)
sma_slow = input(title="Slow SMA (Period)",type=input.integer,minval=1,maxval=500,step=1,defval=50,confirm=false)
ema_medm = input(title="Medm EMA (Period)",type=input.integer,minval=1,maxval=500,step=1,defval=18,confirm=false)
ema_fast = input(title="Fast EMA (Period)",type=input.integer,minval=1,maxval=500,step=1,defval=6,confirm=false)
atr_valu = input(title="ATR (Period)",type=input.integer,minval=1,maxval=500,step=1,defval=14,confirm=false)
ent_canc = input(title="Cancel Entry After X Bars (Period)",type=input.integer,minval=1,maxval=500,step=1,defval=3,confirm=false)

// Create Indicators
slowSMA = sma(close, sma_slow)
medmEMA = ema(close, ema_medm)
fastEMA = ema(close, ema_fast)
bullishPinBar = ((close > open) and ((open - low) > 0.66 * (high - low))) or ((close < open) and ((close - low) > 0.66 * (high - low)))
bearishPinBar = ((close > open) and ((high - close) > 0.66 * (high - low))) or ((close < open) and ((high - open) > 0.66 * (high - low)))
atr = atr(atr_valu)

// Specify Trend Conditions
fanUpTrend = (fastEMA > medmEMA) and (medmEMA > slowSMA)
fanDnTrend = (fastEMA < medmEMA) and (medmEMA < slowSMA)

// Specify Piercing Conditions
bullPierce = ((low < fastEMA) and (open > fastEMA) and (close > fastEMA)) or ((low < medmEMA) and (open > medmEMA) and (close > medmEMA)) or ((low < slowSMA) and (open > slowSMA) and (close > slowSMA))
bearPierce = ((high > fastEMA) and (open < fastEMA) and (close < fastEMA)) or ((high > medmEMA) and (open < medmEMA) and (close < medmEMA)) or ((high > slowSMA) and (open < slowSMA) and (close < slowSMA))
    
// Specify Entry Conditions
longEntry = fanUpTrend and bullishPinBar and bullPierce
shortEntry = fanDnTrend and bearishPinBar and bearPierce

// Long Entry Function
enterlong() =>
    risk = usr_risk * 0.01 * strategy.equity
    stopLoss = low[1] - atr[1] * atr_mult
    entryPrice = high[1]
    units = risk / (entryPrice - stopLoss)
    strategy.entry("long", strategy.long, units, stop=entryPrice)
    strategy.exit("exit long", from_entry="long", trail_points=slPoints, trail_offset=slOffset)
    
// Short Entry Function
entershort() =>
    risk = usr_risk * 0.01 * strategy.equity
    stopLoss = high[1] + atr[1] * atr_mult
    entryPrice = low[1]
    units = risk / (stopLoss - entryPrice)
    strategy.entry("short", strategy.short, units, stop=entryPrice)
    strategy.exit("exit short", from_entry="short", trail_points=slPoints, trail_offset=slOffset)
    
// Execute Long Entry
if (longEntry)
    enterlong()

// Execute Short Entry
if (shortEntry)
    entershort() 
    
// Cancel the Entry if Bar Time is Exceeded
strategy.cancel("long", barssince(longEntry) > ent_canc)
strategy.cancel("short", barssince(shortEntry) > ent_canc)

// Force Close During Certain Conditions
strategy.close_all(when = hour==16 and dayofweek==dayofweek.friday, comment = "exit all, market-closed")
strategy.close_all(when = crossunder(fastEMA, medmEMA), comment = "exit long, re-cross")
strategy.close_all(when = crossover(fastEMA, medmEMA), comment = "exit short, re-cross")

// Plot Moving Averages to Chart
plot(fastEMA, color=color.red)
plot(medmEMA, color=color.blue)
plot(slowSMA, color=color.green)

// Plot Pin Bars to Chart
plotshape(bullishPinBar, text='Bull PB', style=shape.labeldown, location=location.abovebar, color=color.green, textcolor=color.white, transp=0)
plotshape(bearishPinBar, text='Bear PB', style=shape.labelup, location=location.belowbar, color=color.red, textcolor=color.white, transp=0)

// Plot Days of Week
plotshape(hour==0 and dayofweek==dayofweek.monday, text='Monday', style=shape.labeldown, location=location.abovebar, color=color.black, textcolor=color.white, transp=0)
plotshape(hour==0 and dayofweek==dayofweek.tuesday, text='Tuesday', style=shape.labeldown, location=location.abovebar, color=color.black, textcolor=color.white, transp=0)
plotshape(hour==0 and dayofweek==dayofweek.wednesday, text='Wednesday', style=shape.labeldown, location=location.abovebar, color=color.black, textcolor=color.white, transp=0)
plotshape(hour==0 and dayofweek==dayofweek.thursday, text='Thursday', style=shape.labeldown, location=location.abovebar, color=color.black, textcolor=color.white, transp=0)
plotshape(hour==0 and dayofweek==dayofweek.friday, text='Friday', style=shape.labeldown, location=location.abovebar, color=color.black, textcolor=color.white, transp=0)
plotshape(hour==16 and dayofweek==dayofweek.friday, text='Market Closed', style=shape.labeldown, location=location.abovebar, color=color.black, textcolor=color.white, transp=0)









더 많은