
MACD BB波段突破戦略は,MACD指数とブリン帯の指数に基づいた取引戦略である.この戦略は,MACD指数を使用して市場の短期的なトレンドを捉え,同時にブリン帯の指数を使用して市場の超買いと超売り領域を特定する.MACD指数がブリン帯を突破すると,戦略は多項を開く.MACD指数がブリン帯を突破すると,戦略は空券を開く.この戦略は,市場の短期的なトレンドを捉え,傾向が形成される初期の段階で取引する.
MACD BB波段の突破策の原理は以下の通りである.
MACD BB波段突破戦略は,MACD指標とブリン帯指標を組み合わせて,トレンド形成の初期段階で取引する.戦略の優点は,短期トレンドを捉え,価格の変動性を考慮することにあるが,幅度リスク,頻繁な取引,パラメータの最適化という課題にも直面する.トレンド確認,動的ストップ損失,パラメータの自己適応などの最適化方向によって,戦略の安定性と適応性をさらに向上させることができる.
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
//AK MACD BB
strategy("AK MACD BB strategy", overlay = true)
// Inputs for TP and SL
tp_percent = input.float(1.0, title="Take Profit %") / 100
sl_percent = input.float(1.0, title="Stop Loss %") / 100
length = input.int(10, minval=1, title="BB Periods")
dev = input.float(1, minval=0.0001, title="Deviations")
//MACD
fastLength = input.int(12, minval=1, title="fastLength")
slowLength=input.int(26,minval=1)
signalLength=input.int(9,minval=1)
fastMA = ta.ema(close, fastLength)
slowMA = ta.ema(close, slowLength)
macd = fastMA - slowMA
//BollingerBands
Std = ta.stdev(macd, length)
Upper = (Std * dev + (ta.sma(macd, length)))
Lower = ((ta.sma(macd, length)) - (Std * dev))
Band1 = plot(Upper, color=color.gray, style=plot.style_line, linewidth=2,title="Upper Band")
Band2 = plot(Lower, color=color.gray, style=plot.style_line, linewidth=2,title="lower Band")
fill(Band1, Band2, color=color.blue, transp=75,title="Fill")
mc = macd >= Upper ? color.lime:color.red
// Indicator
plot(macd, color=mc, style =plot.style_circles,linewidth = 3, title="macd")
zeroline = 0
plot(zeroline,color= color.orange,linewidth= 2,title="Zeroline")
//buy
barcolor(macd >Upper ? color.yellow:na)
//short
barcolor(macd <Lower ? color.aqua:na)
if macd > Upper
strategy.entry("Long", strategy.long)
// strategy.exit("Long TP/SL", "Long", limit=close * (1 + tp_percent), stop=close * (1 - sl_percent), comment = "Long Exit" )
if macd < Lower
strategy.entry("Short", strategy.short)
// strategy.exit("Short TP/SL", "Short", limit=close * (1 - tp_percent), stop=close * (1 + sl_percent), comment = "Short Exit")