動向平均値によるサイクル判断に基づくモメントブレイク戦略

作者: リン・ハーンチャオチャン,日付: 2024-01-23 14:51:27
タグ:

img

概要

この戦略は,市場の現在のサイクル段階を決定するために,異なる期間のEMA線を計算し,高確率のトレンドフォロー取引のためのモメンタムブレイクシグナルを生成するためにATRを使用します.

戦略の論理

  1. 計算する EMA線は 5 日,20 日および 40 日です.
  2. EMA線を比較して,6つのサイクル段階のうち,市場が現在どの段階にあるかを決定します.
    • 5 日 > 20 日 > 40 日 は サイクル 1
    • 20 日 > 5 日 > 40 日 は サイクル 2 ... ほら
  3. サイクルを決定した後,ATR指標を計算し,ATR倍数を割り込み基準として設定する.
  4. 価格が前回のバーのATRトレーリングストップを超えると購入信号が生成されます.
  5. 売り信号は,価格が前回のバーのATRトレーリングストップを下回るときに生成されます.
  6. この判断の組み合わせによって,高い確率のトレンドフォロー取引が達成できます.

利点

  1. サイクルの判断は信号の信頼性を高める

    異なるEMA線の相対位置を判断することで,市場の現在のサイクル段階を効果的に決定し,不適切なサイクルにおける誤った信号を回避できます.

  2. ATRの突破は 偽信号をフィルターします

    ATRは市場の波動性を効果的に表すことができる.ブレイクアウト基準としてATR倍数を設定することで,多くの誤ったブレイクアウト信号をフィルタリングすることができます.

  3. 判断の組み合わせは,高い確率の取引機会を生み出します

    サイクル判断とATRブレイクの有機的な組み合わせは,より高い確率の信号を生み出し,取引の収益性を高めます.

リスク

  1. 難しいパラメータ最適化

    複数のパラメータがある場合,最適化の難易度は高く,パラメータの設定が正しくない場合,戦略のパフォーマンスに影響を与える可能性があります.

  2. 遅滞は存在します

    急速に変化する市場では,EMAとATRの両方が一定の遅れを呈し,間違った信号や機会を逃す可能性があります.

  3. ストップ損失を厳格に要求する

    誤った信号を完全に回避できる技術指標はありません.リスクを制御するために厳格なストップロスは必要です.

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

  1. パラメータのさらなる最適化

    より広範な歴史的データを通して最適なパラメータの組み合わせを見つけます

  2. 適応力を高める

    適応性を向上させるため,市場変動に基づいてATRパラメータを自動的に調整することを検討する.

  3. 他の指標を組み込む

    判断や信号品質を改善するために 波動性と音量などの他の指標を組み込むことを試してみてください

結論

この戦略は,EMAでサイクルを決定し,ATRでモメンタムブレイクアウト基準を設定し,高い確率のトレンドフォロー取引を達成する. サイクル判断,偽信号フィルタリング,信号品質改善などの利点があります. しかし,難しいパラメータ最適化や遅延などのリスクがあります.パラメータ,適応性などのさらなる最適化は戦略を改善することができます.


/*backtest
start: 2024-01-15 00:00:00
end: 2024-01-22 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kgynofomo

//@version=5
strategy(title="[Salavi] | Andy Advance Pro Strategy",overlay = true)

ema_short = ta.ema(close,5)
ema_middle = ta.ema(close,20)
ema_long = ta.ema(close,40)

cycle_1 = ema_short>ema_middle and ema_middle>ema_long
cycle_2 = ema_middle>ema_short and ema_short>ema_long
cycle_3 = ema_middle>ema_long and ema_long>ema_short
cycle_4 = ema_long>ema_middle and ema_middle>ema_short
cycle_5 = ema_long>ema_short and ema_short>ema_middle
cycle_6 = ema_short>ema_long and ema_long>ema_middle

bull_cycle = cycle_1 or cycle_2 or cycle_3
bear_cycle = cycle_4 or cycle_5 or cycle_6
// label.new("cycle_1")
// bgcolor(color=cycle_1?color.rgb(82, 255, 148, 60):na)
// bgcolor(color=cycle_2?color.rgb(82, 255, 148, 70):na)
// bgcolor(color=cycle_3?color.rgb(82, 255, 148, 80):na)
// bgcolor(color=cycle_4?color.rgb(255, 82, 82, 80):na)
// bgcolor(color=cycle_5?color.rgb(255, 82, 82, 70):na)
// bgcolor(color=cycle_6?color.rgb(255, 82, 82, 60):na)

// Inputs
a = input(2, title='Key Vaule. \'This changes the sensitivity\'')
c = input(7, title='ATR Period')
h = false

xATR = ta.atr(c)
nLoss = a * xATR

src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close

xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2

pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3

xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue

ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)

buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below

barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop




atr = ta.atr(14)
atr_length = input.int(25)
atr_rsi = ta.rsi(atr,atr_length)
atr_valid = atr_rsi>50

long_condition =  buy and bull_cycle and atr_valid
short_condition =  sell and bear_cycle and atr_valid

Exit_long_condition = short_condition
Exit_short_condition = long_condition

if long_condition
    strategy.entry("Andy Buy",strategy.long, limit=close,comment="Andy Buy Here")

if Exit_long_condition
    strategy.close("Andy Buy",comment="Andy Buy Out")
    // strategy.entry("Andy fandan Short",strategy.short, limit=close,comment="Andy 翻單 short Here")
    // strategy.close("Andy fandan Buy",comment="Andy short Out")


if short_condition
    strategy.entry("Andy Short",strategy.short, limit=close,comment="Andy short Here")


// strategy.exit("STR","Long",stop=longstoploss)
if Exit_short_condition
    strategy.close("Andy Short",comment="Andy short Out")
    // strategy.entry("Andy fandan Buy",strategy.long, limit=close,comment="Andy 翻單 Buy Here")
    // strategy.close("Andy fandan Short",comment="Andy Buy Out")




inLongTrade = strategy.position_size > 0
inLongTradecolor = #58D68D
notInTrade = strategy.position_size == 0
inShortTrade = strategy.position_size < 0

// bgcolor(color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)
plotshape(close!=0,location = location.bottom,color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)


plotshape(long_condition, title='Buy', text='Andy Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(short_condition, title='Sell', text='Andy Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)


//atr > close *0.01* parameter

もっと