
この戦略は,ブリン帯 ((Bollinger Bands)) と5日指数移動平均 ((5-day EMA)) を組み合わせて取引信号を生成する.価格がブリン帯を超えて軌道に乗って5日EMAより低い値で閉じる時,空頭ポジションを開く;価格がブリン帯を下回って5日EMAより高い値で閉じる時,多頭ポジションを開く.同時に,逆行シグナルが発生すると,戦略は既存のポジションを平らにして新しい逆行ポジションを開く.この戦略は,市場の波動性とトレンドの変化を捉え,ブリンによって価格の相対的な高低を判断し,トレンドのとしてEMAを利用して,この取引信号を生成する.
この戦略は,ブリン帯とEMAを組み合わせることで,トレンドの機会と波動の機会を比較的に効果的に捕捉し,中長期の取引戦略に適用できます.しかし,パラメータの最適化,ポジションの制御,リスクの管理に注意し,他の技術指標と基本的分析と組み合わせることで,戦略の有効性をよりよく発揮することができます.戦略のパフォーマンスは,市場の状況に影響され,実際の状況に応じて調整および最適化する必要があります.
/*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("Bollinger Bands and EMA Strategy", overlay=true)
// Define the Bollinger Bands
length = input.int(20, title="BB Length")
src = input(close, title="BB Source")
mult = input.float(2.0, title="BB Multiplier")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
// Plot Bollinger Bands
plot(upper, "Upper Band", color=color.red)
plot(lower, "Lower Band", color=color.green)
plot(basis, "Middle Band", color=color.blue) // Use plot instead of hline for basis
// Define the 5-period EMA
ema5 = ta.ema(close, 5)
// Plot the 5 EMA
plot(ema5, "5 EMA", color=color.orange)
// Generate signals
var float entry_price = na
var string trade_direction = "none"
if (na(close[1]))
trade_direction := "none"
// Condition for entering a short trade
if (open > upper and close < ema5)
if (trade_direction != "short")
strategy.entry("Short", strategy.short)
entry_price := close
trade_direction := "short"
// Condition for entering a long trade
if (open < lower and close > ema5)
if (trade_direction != "long")
strategy.entry("Long", strategy.long)
entry_price := close
trade_direction := "long"
// Close short trade on a long signal
if (trade_direction == "short" and open < lower and close > ema5)
strategy.close("Short")
strategy.entry("Long", strategy.long)
entry_price := close
trade_direction := "long"
// Close long trade on a short signal
if (trade_direction == "long" and open > upper and close < ema5)
strategy.close("Long")
strategy.entry("Short", strategy.short)
entry_price := close
trade_direction := "short"
// Close trades when opposite signal is generated
if (trade_direction == "long" and open > upper and close < ema5)
strategy.close("Long")
trade_direction := "none"
if (trade_direction == "short" and open < lower and close > ema5)
strategy.close("Short")
trade_direction := "none"