双 EMA 交差振動追跡戦略

作者: リン・ハーンチャオチャン, 日付: 2024-01-03 11:38:51
タグ:

img

概要

ダブルEMAクロスオーバー振動追跡戦略 (Dual EMA Crossover Oscillation Tracking strategy) は,EMA指標を用いてトレンドを特定し,不安定な市場状況下で振動を追跡する戦略である.この戦略にはトレンド追跡と振動捕捉の両方の概念が含まれている.強力なトレンドの間,長期追跡と振動の間,短期取引を行うことでより良い収益を達成することを目的としている.

戦略の論理

この戦略は,傾向を判断するための指標として20期間のEMAを使用します.価格がEMAを超えると上昇傾向を示し,価格が以下を超えると下落傾向を示します.

価格がEMAを超えると,過去20期間の最も高い価格をメリット引き上げとして,クロスオーバー以降の最低値をストップ・ロスとして使用してロングポジションを入力します.価格がEMAを下回ると,過去20期間の最も低い価格をメリット引き上げとして,クロスオーバー以降の最高値をストップ・ロスとして使用してショートポジションを入力します.

同時に,この戦略は,ADXが30を超えているかどうかをチェックする.トレンドが十分に強いとき,すなわちADXが30を超えると取引が行われる.これは市場の振動中にストップアウトを避ける.

オープン・トレードでは トレーリング・ストップは 市場の状況に応じて 調整され続け より多くの利益を得ることができます

利点分析

この戦略は,トレンドトラッキングと振動取引の両方の利点を組み合わせます. 傾向市場ではより高い収益を生み出し,振動中により一貫した収益を生み出します. 適応性は強いです.

EMAの使用は,パラメータをシンプルに保ち,過度に最適化するリスクを低減し,安定性を確保します.

リスク分析

この戦略の主なリスクは,激化した振動中により頻繁にストップアウトする可能性である.ここではADXが登場する.ADXが低いときに取引を無効にし,明確なトレンドがない場合の損失を回避することができる.

また,適切なストップ・ロスの配置も鍵となる.過剰に広いストップは単一の取引損失額を増やす可能性がある.過度に緊密なストップは過度に敏感であり,ストップアウト確率を増やす可能性がある.利益目標とストップ・ロスのリスクの間にバランスが求められる必要がある.

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

この戦略の可能な最適化には,以下が含まれます.

  1. 最適な組み合わせを見つけるために EMA期間をテストする

  2. ADX 期間と値を含む ADX パラメータの最適化

  3. 収益とストップ・ロスのアルゴリズムを改良し,例えば動的ストップを導入する.

  4. KDJとMACDのような追加指標を組み合わせて 多指標の確認システムを作ります

概要

概要すると,ダブルEMAクロスオーバー振動追跡戦略は,非常に実践的な戦略である.トレンドトレーディング戦略と振動戦略の両方の強みを組み合わせている.長期トレーリングと短期トレーディングの両方に使用できる.パラメータ最適化と確認指標を追加することにより,パフォーマンスのさらなる改善を達成することができる.市場状況に関する一定のレベルの分析能力を持つ投資家に適している.


/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-02 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Linda Raschke's Holy Grail", shorttitle="RHG", default_qty_type = strategy.percent_of_equity, default_qty_value = 100, overlay = true)
adxlen = input(14, title="ADX period")
adxMin = input(30)
dilen = adxlen
f_highest(_src, _length)=>
    _adjusted_length = _length < 1 ? 1 : _length
    _value = _src
    for _i = 0 to (_adjusted_length-1)
        _value := _src[_i] >= _value ? _src[_i] : _value
    _return = _value

f_lowest(_src, _length)=>
    _adjusted_length = _length < 1 ? 1 : _length
    _value = _src
    for _i = 0 to (_adjusted_length-1)
        _value := _src[_i] <= _value ? _src[_i] : _value
    _return = _value

dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

emaLength = input(20)
curEma = ema(close, emaLength)
highPeriod = input(20)
d = na

takeProfitLong = highest(high, highPeriod) 
stopLossLong = f_lowest(low, barssince(low >= curEma))

if strategy.position_size == 0
    if adx(dilen, adxlen) <= adxMin or high < curEma 
        strategy.cancel("Long")
    if adx(dilen, adxlen) > adxMin and low < curEma and high > curEma and curEma > curEma[highPeriod / 2] and curEma > curEma[highPeriod] and takeProfitLong > high
        strategy.order("Long", strategy.long, stop = high)
        strategy.exit("Exit", "Long", limit = takeProfitLong, stop = stopLossLong)
        d := high

takeProfitShort = lowest(low, highPeriod) 
stopLossShort = f_highest(high, barssince(high <= curEma))

if strategy.position_size == 0
    if adx(dilen, adxlen) <= adxMin or low > curEma 
        strategy.cancel("Short")
    if adx(dilen, adxlen) > adxMin and high > curEma and low < curEma and curEma < curEma[highPeriod / 2] and curEma < curEma[highPeriod] and takeProfitShort < low
        strategy.order("Short", strategy.short, stop = low)
        strategy.exit("Exit", "Short", limit = takeProfitShort, stop = stopLossShort)
        d := low


strategy.close("Exit")

plot(d == high ? stopLossLong : d == low ? stopLossShort : na, style = circles, linewidth = 4, color = red)
plot(d == high ? takeProfitLong : d == low ? takeProfitShort : na, style = circles, linewidth = 4, color = green)
plot(d, style = circles, linewidth = 4, color = yellow)
plot(curEma, color = black, linewidth = 2)  

// === Backtesting Dates ===
testPeriodSwitch = input(false, "Custom Backtesting Dates")
testStartYear = input(2018, "Backtest Start Year")
testStartMonth = input(3, "Backtest Start Month")
testStartDay = input(6, "Backtest Start Day")
testStartHour = input(08, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
testStopYear = input(2018, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(14, "Backtest Stop Day")
testStopHour = input(14, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
isPeriod = testPeriodSwitch == true ? testPeriod() : true
// === /END
if not isPeriod
    strategy.cancel_all()
    strategy.close_all()


もっと