この戦略は,強化されたMACD指標に基づいてトレンド追跡を行う.それは,同時に,迅速な移動平均,遅い移動平均,および両者の差値を計算し,差値の移動平均を計算して取引信号を生成する.
具体的にはこうです
EMA周期を計算する.例えば12日
ゆっくりとしたEMA周期,例えば26日
EMAの差をMACDで計算する
MACDに対する信号線EMA,例えば9日EMA
MACDと信号線の差値を EMA にかけると,増幅信号線が生成される.
増幅信号線でゼロ軸を横切るときに多めに
増強信号線下でのゼロ軸穿越時に平多ポジション
この戦略は,MACD指標のトレンド追跡特性を充分に活用し,二次最適化フィルターを行い,信号の質を向上させ,中長線トレンドを追求する.
強化MACD静音化により信号の正確性
EMAの判断と努力の方向に 徐々に協力する
遅いパラメータを中心に長線トレンド
EMA周期パラメータを慎重に選択する
余分な努力だけでは空き席を利用できない.
信号の発生頻度は低い
この戦略は,MACDのトレンド追跡能力を強化することで中長線の機会を識別する.しかし,パラメータ最適化とリスク管理は特に重要です.他の要因の適切な組み合わせは,効果を高める.
/*backtest
start: 2022-09-07 00:00:00
end: 2023-09-13 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
//study("MACDAS")
// strategy("macdas",shorttitle="macdas",overlay=true,default_qty_value=10000,initial_capital=10000,currency=currency.USD)
// Date range filter
testStartYear = input(2018, "Backtest Start Year")
testStartMonth = input(4, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)
testStopYear = input(2018, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(31, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)
inTimeRange = true
fastperiod = input(12,title="fastperiod",minval=1,maxval=500)
slowperiod = input(26,title="slowperiod",minval=1,maxval=500)
signalperiod = input(9,title="signalperiod",minval=1,maxval=500)
fastMA = ema(close, fastperiod)
slowMA = ema(close, slowperiod)
macd = fastMA - slowMA
signal = ema(macd, signalperiod)
macdAS = macd - signal
signalAS = ema(macdAS, signalperiod)
plot(macdAS, color=blue, linewidth=2)
plot(signalAS, color=red, linewidth=2)
plot(0, color=black)
strategy.entry("LONG", strategy.long, when =inTimeRange and crossover(macdAS,signalAS))
strategy.close("LONG", when= inTimeRange and crossunder(macdAS,signalAS))
plotshape(crossover(macdAS, signalAS) , style = shape.arrowup, text="Long",color=green,size=size.huge)
plotshape(crossover(signalAS,macdAS) , style = shape.arrowdown, text="End Long",color=red,size=size.huge)