
이 전략은 주로 특정 K선 형태인 핀 바 (Pin Bar) 를 식별하여 잠재적인 시장 전환점을 판단한다. 핀 바 (Pin Bar) 는 긴 그림자와 작은 개체로 구성된 K선 형태이며, 시장이 그 지점에서 큰 변동이 있었지만, 최종 가격 회수로 인해 지점이 지지 또는 저항 지점일 수 있음을 보여줍니다. 이 전략은 50주기 간단한 이동 평균 (SMA) 을 사용하여 현재 트렌드 방향을 판단하고, 20주기 SMA를 거래량 필터링 조건으로 사용하며, 거래량이 이 평균선보다 크면만 유효한 신호로 간주됩니다.
핀 바 역전 전략은 간단한 효과적인 사고 방식을 채택하고, 트렌드 필터, 거래량 필터 등의 방법으로 신호 식별의 정확도를 향상시킵니다. 현재 개선할 수 있는 부분이 있지만, 전체적인 사고방식은 실행 가능하며, 추가적인 최적화 테스트를 할 가치가 있습니다. 핀 바 자체는 고전적인 가격 형태로서 다른 지표 또는 신호와 결합하여 더 안정적인 거래 시스템을 얻을 수 있습니다.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Filtered Pin Bar Strategy with Relaxed Volume", overlay=true)
// Define the size of the pin bar's wick and body
wickSize = 0.6
bodySize = 0.3
// Calculate the size of the wicks and body
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low
body = math.abs(close - open)
// Define a simple moving average to determine the trend
smaLength = 50
sma = ta.sma(close, smaLength)
// Define a more relaxed volume threshold
volumeThreshold = ta.sma(volume, 20) * 1.0
// Define RSI parameters
rsiLength = 14
rsiOverbought = 70
rsiOversold = 30
rsi = ta.rsi(close, rsiLength)
// Define the conditions for a bullish pin bar
bullishPinBar = (lowerWick > (wickSize * (high - low))) and
(body < (bodySize * (high - low))) and
(close > open) and
(close > sma) and
(volume > volumeThreshold)
// Define the conditions for a bearish pin bar
bearishPinBar = (upperWick > (wickSize * (high - low))) and
(body < (bodySize * (high - low))) and
(close < open) and
(close < sma) and
(volume > volumeThreshold)
// Plot the bullish and bearish pin bars on the chart
plotshape(series=bullishPinBar, title="Bullish Pin Bar", location=location.belowbar, color=color.green, style=shape.labelup, text="PB")
plotshape(series=bearishPinBar, title="Bearish Pin Bar", location=location.abovebar, color=color.red, style=shape.labeldown, text="PB")
// Entry and exit rules
if (bullishPinBar)
strategy.entry("Bullish Pin Bar", strategy.long)
if (bearishPinBar)
strategy.entry("Bearish Pin Bar", strategy.short)
// Optional: Set stop loss and take profit
stopLoss = 2 * body
takeProfit = 3 * body
strategy.exit("Exit Long", from_entry="Bullish Pin Bar", stop=low - stopLoss, limit=high + takeProfit)
strategy.exit("Exit Short", from_entry="Bearish Pin Bar", stop=high + stopLoss, limit=low - takeProfit)