動的移動平均トレンドクロスオーバー戦略

作者: リン・ハーンチャオチャン, 日付: 2023年11月21日 17:18:20
タグ:

img

概要

ダイナミック・ムービング・アベア・トレンド・クロスオーバー戦略 (Dynamic Moving Average Trend Crossover Strategy) は,ムービング・アベア・コンバージェンス・ディバージェンスの指標 (MACD) をベースとした取引システムである.この戦略は,短期間の移動平均値と長期間の移動平均値の違いをベースに,購入または売却の決定を行う.主なアイデアは,短期間のトレンドと長期間のトレンドの関係を監視し,潜在的な市場変化を予測することである.

戦略原則

この戦略は,2つの異なる期間の指数関数移動平均値 (EMA) を利用する. 急速なEMA (8日) と遅いEMA (16日). MACD値はこれらの2つのEMAの違いから派生する. さらに,この戦略には11日間のMACDの単純な移動平均値 (SMA) であるシグナルラインが含まれています. MACD線がシグナルラインの上を横切ると買い信号が生成され,上昇傾向を示し,下を横切ると売り信号が表示されます.

コードレベルでは,戦略は,高速と遅いEMAを計算し,その後MACD値を導き出す.その後,MACDのSMAは信号ラインとして計算される.ポジションはMACDの位置と信号ラインを比較することによって決定される.さらに,戦略は逆取引オプションを提供し,反対の信号で市場に参入することを可能にする.

戦略 の 利点

ダイナミック・ムービング・平均トレンド・クロスオーバー戦略の主な利点は,市場のトレンドの変化に対するシンプルさと敏感性にある.異なる期間のEMAを使用することで,この戦略は短期的および長期的トレンドの間の偏差を効果的に把握し,市場変化に適時に対応する.信号線を追加することで,戦略の正確性がさらに向上し,投資家がトレンド逆転をより早く特定できるようになります.

リスク分析

ダイナミック・ムービング・平均トレンド・クロスオーバー戦略は,多くの状況でうまく機能するが,一定のリスクも伴う.主なリスクは,非常に不安定な市場や不明確なトレンドにおける誤解を招く信号の生成である.また,歴史的データへの依存は,遅延した応答につながる可能性がある.これらのリスクを軽減するために,投資家は,戦略を他の技術指標または市場分析と組み合わせて意思決定を行うことができる.

オプティマイゼーションの方向性

この戦略の最適化には,EMA期間の長さを調整し,追加の技術指標を組み込み,市場変動要因を考慮することが含まれる. 期間長さを調整することで,戦略が異なる市場状況により適応できるようになります.

RSIまたはボリンジャー帯は,市場のより包括的な見方を提供することができます. ATRで戦略を調整するなどの市場の変動要因を考慮すると,戦略の適応性と強度が向上します.

結論

ダイナミック・ムービング・平均トレンド・クロスオーバー戦略 (Dynamic Moving Average Trend Crossover Strategy) は,MACDを中心とした定量的なトレード戦略である.短期的・長期的トレンドの関係を分析することによって市場の動きを把握することを目的としている.この戦略は単純で効果的であるが,その限界と潜在的なリスクを知ることは重要である.他の分析ツールを継続的に最適化し統合することで,投資家は効果的な市場運用のためにこの戦略をよりうまく利用することができる.


/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 06/09/2017
// MACD – Moving Average Convergence Divergence. The MACD is calculated 
// by subtracting a 26-day moving average of a security's price from a 
// 12-day moving average of its price. The result is an indicator that 
// oscillates above and below zero. When the MACD is above zero, it means 
// the 12-day moving average is higher than the 26-day moving average. 
// This is bullish as it shows that current expectations (i.e., the 12-day 
// moving average) are more bullish than previous expectations (i.e., the 
// 26-day average). This implies a bullish, or upward, shift in the supply/demand 
// lines. When the MACD falls below zero, it means that the 12-day moving average 
// is less than the 26-day moving average, implying a bearish shift in the 
// supply/demand lines.
// A 9-day moving average of the MACD (not of the security's price) is usually 
// plotted on top of the MACD indicator. This line is referred to as the "signal" 
// line. The signal line anticipates the convergence of the two moving averages 
// (i.e., the movement of the MACD toward the zero line).
// Let's consider the rational behind this technique. The MACD is the difference 
// between two moving averages of price. When the shorter-term moving average rises 
// above the longer-term moving average (i.e., the MACD rises above zero), it means 
// that investor expectations are becoming more bullish (i.e., there has been an 
// upward shift in the supply/demand lines). By plotting a 9-day moving average of 
// the MACD, we can see the changing of expectations (i.e., the shifting of the 
// supply/demand lines) as they occur.
//  You can change long to short in the Input Settings
//  WARNING:
//  - For purpose educate only
//  - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="MACD Crossover", shorttitle="MACD Crossover")
fastLength = input(8, minval=1)
slowLength = input(16,minval=1)
signalLength=input(11,minval=1)
reverse = input(false, title="Trade reverse")
// hline(0, color=purple, linestyle=dashed)
fastMA = ema(close, fastLength)
slowMA = ema(close, slowLength)
macd = fastMA - slowMA
signal = sma(macd, signalLength)
pos = iff(signal < macd , 1,
	   iff(signal > macd, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )  
plot(signal, color=red, title="SIGNAL")
plot(macd, color=blue, title="MACD")


もっと