ダブル・ムービング・平均リバース・トラッキング戦略は,移動平均クロスオーバーを取引信号として利用する定量的な取引戦略である.この戦略は,MACD指標の快速・遅速移動平均差とその信号線,および取引量の長/短比を組み合わせ,取引信号を形成し,市場の逆転機会を把握する.
この戦略は,主に高速線とスローラインの関係を判断する.高速線がスローラインを越えたときに購入信号,高速線がスローラインを越えたときに販売信号を生成する.また,MACD差値の長/短状態,差と信号線の関係,取引量の長/短状況などに基づいて市場の長/短状態を包括的に判断する.
特に,戦略はMACD差値の大きさと方向,差と信号線との間のクロスオーバー,差と信号線との間の一貫したまたは反対の方向などを判断する.これらの状況は,下跌後のサブ市場のリバウンド特性を反映する.さらに,取引量の長/短分布も補助判断指標として使用される.
差と信号線が市場逆転の信号を示し,取引量は市場の逆転を確認するように一致すると,取引信号が生成されます.
ダブル・ムービング・平均回転追跡戦略は,移動平均値,MACD,取引量などの指標を包括的に考慮する.それらの逆転信号をキャプチャすることによって,ポジションを確立するために適切な逆転ポイントが選択される.この戦略を最適化するにはまだ大きな余地があり,機械学習やリスク管理などの技術によって強度と収益性がさらに向上することができる.
/*backtest start: 2024-01-20 00:00:00 end: 2024-02-19 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("3 10 Oscillator Profile Flagging", shorttitle="3 10 Oscillator Profile Flagging", overlay=true) signalBiasValue = input(title="Signal Bias", defval=0.26) macdBiasValue = input(title="MACD Bias", defval=0.8) shortLookBack = input( title="Short LookBack", defval=3) longLookBack = input( title="Long LookBack", defval=10) fast_ma = ta.sma(close, 3) slow_ma = ta.sma(close, 10) macd = fast_ma - slow_ma signal = ta.sma(macd, 16) hline(0, "Zero Line", color = color.black) buyVolume = volume*((close-low)/(high-low)) sellVolume = volume*((high-close)/(high-low)) buyVolSlope = buyVolume - buyVolume[1] sellVolSlope = sellVolume - sellVolume[1] signalSlope = ( signal - signal[1] ) macdSlope = ( macd - macd[1] ) //plot(macdSlope, color=color.red, title="Total Volume") //plot(signalSlope, color=color.green, title="Total Volume") intrabarRange = high - low getLookBackSlope(lookBack) => signal - signal[lookBack] getBuyerVolBias(lookBack) => j = 0 for i = 1 to lookBack if buyVolume[i] > sellVolume[i] j += 1 j getSellerVolBias(lookBack) => j = 0 for i = 1 to lookBack if sellVolume[i] > buyVolume[i] j += 1 j getVolBias(lookBack) => float b = 0 float s = 0 for i = 1 to lookBack b += buyVolume[i] s += sellVolume[i] b > s getSignalBuyerBias(lookBack) => j = 0 for i = 1 to lookBack if signal[i] > signalBiasValue j += 1 j getSignalSellerBias(lookBack) => j = 0 for i = 1 to lookBack if signal[i] < ( 0 - signalBiasValue ) j += 1 j getSignalNoBias(lookBack) => j = 0 for i = 1 to lookBack if signal[i] < signalBiasValue and signal[i] > ( 0 - signalBiasValue ) j += 1 j getPriceRising(lookBack) => j = 0 for i = 1 to lookBack if close[i] > close[i + 1] j += 1 j getPriceFalling(lookBack) => j = 0 for i = 1 to lookBack if close[i] < close[i + 1] j += 1 j getRangeNarrowing(lookBack) => j = 0 for i = 1 to lookBack if intrabarRange[i] < intrabarRange[i + 1] j+= 1 j getRangeBroadening(lookBack) => j = 0 for i = 1 to lookBack if intrabarRange[i] > intrabarRange[i + 1] j+= 1 j bool isNegativeSignalReversal = signalSlope < 0 and signalSlope[1] > 0 bool isNegativeMacdReversal = macdSlope < 0 and macdSlope[1] > 0 bool isPositiveSignalReversal = signalSlope > 0 and signalSlope[1] < 0 bool isPositiveMacdReversal = macdSlope > 0 and macdSlope[1] < 0 bool hasBearInversion = signalSlope > 0 and macdSlope < 0 bool hasBullInversion = signalSlope < 0 and macdSlope > 0 bool hasSignalBias = math.abs(signal) >= signalBiasValue bool hasNoSignalBias = signal < signalBiasValue and signal > ( 0 - signalBiasValue ) bool hasSignalBuyerBias = hasSignalBias and signal > 0 bool hasSignalSellerBias = hasSignalBias and signal < 0 bool hasPositiveMACDBias = macd > macdBiasValue bool hasNegativeMACDBias = macd < ( 0 - macdBiasValue ) bool hasBullAntiPattern = ta.crossunder(macd, signal) bool hasBearAntiPattern = ta.crossover(macd, signal) bool hasSignificantBuyerVolBias = buyVolume > ( sellVolume * 1.5 ) bool hasSignificantSellerVolBias = sellVolume > ( buyVolume * 1.5 ) // 7.48 Profit 52.5% if ( hasSignificantBuyerVolBias and getPriceRising(shortLookBack) == shortLookBack and getBuyerVolBias(shortLookBack) == shortLookBack and hasPositiveMACDBias and hasBullInversion) strategy.entry("Short1", strategy.short) strategy.exit("TPS", "Short1", limit=strategy.position_avg_price - 0.75, stop=strategy.position_avg_price + 0.5) // 32.53 Profit 47.91% if ( getPriceFalling(shortLookBack) and (getVolBias(shortLookBack) == false) and signalSlope < 0 and hasSignalSellerBias) strategy.entry("Long1", strategy.long) strategy.exit("TPS", "Long1", limit=strategy.position_avg_price + 0.75, stop=strategy.position_avg_price - 0.5)