
この戦略は,主に特定のK線形状であるピンバーを識別することによって,潜在的な市場逆転点を判断する.ピンバーは,長影線と小さな実体で構成される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)