指数関数移動平均のクロスオーバー戦略

作者: リン・ハーンチャオチャン開催日:2024年1月12日 (火) 14:04:37
タグ:

img

指数関数移動平均 (EMA) クロスオーバーは,一般的な取引信号である.この戦略は,高速EMAと遅いEMAのクロスオーバーを使用して取引信号を生成する.特に,高速EMAが遅いEMAの上に横切ると,ロングポジションが取られ,高速EMAが遅いEMA以下に横切ると,ショートポジションが取られる.

この戦略では,20日間のEMAが高速EMA,50日間のEMAが中間EMA,200日間のEMAがスローEMAとして使用されます. 20日間のEMAと50日間のEMAが両方とも200日間のEMAを超えると,ロングポジションがとられ,両方が下を横切ると,ショートポジションがとられます.これはいくつかの誤った信号をフィルタリングするのに役立ちます.

戦略 の 利点

  1. 移動平均のクロスオーバー戦略は単純で理解し実行しやすい
  2. 複数の移動平均値 を 使う こと は,誤った 信号 を フィルタリング する 助け に なり ます
  3. 入口と出口の信号が明瞭だ

戦略 の リスク

  1. 範囲限定市場において誤った信号を生成する傾向がある
  2. 移動平均は遅延があり,すぐに回転を捉えることができません.
  3. 爆発的な動きを完全に利用できない

改良 の アイデア

  1. 異なる製品と時間枠の移動平均期間の最適化
  2. ボリュームやボリンジャー・バンドのようなフィルターを追加します
  3. 柔軟性のためにトレンドフォローと平均逆転を組み合わせる

概要

移動平均クロスオーバー戦略は,理解しやすく,基本的な定量的な取引戦略の1つである.この実装は紹介例としてよく機能する.しかし,ライブ取引では,パラメータは最適化が必要であり,より高度な技術指標がシグナルをフィルターし,パフォーマンスを向上させるために追加されるべきである.


/*backtest
start: 2023-01-05 00:00:00
end: 2024-01-11 00:00:00
period: 1d
basePeriod: 1h
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/
// © rt-maax

//@version=5

strategy(title = "rt maax EMA cross strategy", shorttitle = "rt maax ema ", overlay = true, precision = 8, max_bars_back = 200, pyramiding = 0, initial_capital = 100000, 
     currency = currency.USD, default_qty_type = strategy.cash, default_qty_value = 100000, commission_type = "percent", commission_value = 0.27)
fastema = ta.ema (close , 50)
fema=ta.ema(close,20)
slowema= ta.ema(close,200)
price = close

// === INPUT BACKTEST RANGE ===
fromMonth = input.int(defval = 1,    title = "From Month",  minval = 1, maxval = 12)
fromDay   = input.int(defval = 1,    title = "From Day",    minval = 1, maxval = 31)
fromYear  = input.int(defval = 2021, title = "From Year",   minval = 1970)
thruMonth = input.int(defval = 10,    title = "Thru Month",  minval = 1, maxval = 12)
thruDay   = input.int(defval = 25,    title = "Thru Day",    minval = 1, maxval = 31)
thruYear  = input.int(defval = 2112, title = "Thru Year",   minval = 1970)

// === INPUT SHOW PLOT ===
showDate  = input(defval = true, title = "Show Date Range")

// === FUNCTION EXAMPLE ===



longCondition1= ta.crossover (fema , fastema) 
longcondition2= fema> slowema
longcondition3=fastema>slowema


if (longCondition1 and longcondition2 and longcondition3 )
    stoploss=low*0.97
    takeprofit=high*1.12
    strategy.entry("Long Entry", strategy.long)
    strategy.exit ("exit","long",stop=stoploss,limit=takeprofit)
   


shortCondition1 = ta.crossunder (fema , fastema )
shortcondition2= fastema< slowema
shortcondition3= fema< slowema

if (shortCondition1 and shortcondition2 and shortcondition3 )
    stoploss=low*0.97 
    takeprofit=high*1.5
    strategy.entry("Short Entry", strategy.short)
    strategy.exit("exit","short",stop=stoploss,limit=takeprofit)






もっと