HYE平均逆転 SMA戦略

作者: リン・ハーンチャオチャン, 日付: 2023年12月15日 16:51:23
タグ:

img

概要

HYE Mean Reversion SMA戦略は,単純な移動平均値と相対強度指数 (RSI) を使用した平均逆転取引戦略である.価格は移動平均値から一定のパーセントで逸脱すると,RSI指標のフィルタリングと組み合わせて購入・売却信号を生成する.これは短期的取引戦略である.

戦略の論理

この戦略は主に以下のルールに基づいています

  1. 2 期間の単純な移動平均が 5 期間の単純な移動平均を下回る 3% の場合,価格は平均値から逸脱すると考えられ,購入信号が生成されます.

  2. 2 期間の SMA が 5 期間の SMA を横切ると,価格は平均値に戻ると考えられ,売り信号が生成されます.

  3. 5期間の指数関数移動平均値と組み合わせると,RSIが30未満のときにのみ購入信号が生成され,RSIが70を超えると販売信号が生成され,不必要な取引を避ける.

RSIは,短期間の価格変動を用いて平均逆転機会を捕捉することである.価格が一定パーセント下落すると購入し,価格が移動平均値に近い値に戻ると売却し,利益を得ることである.一方,RSIインジケーターは,いくつかの騒々しい取引信号をフィルタリングするために,過剰購入および過剰販売条件を特定することができます.

利点分析

この戦略には以下の利点があります.

  1. 低監視コストで 簡単に実行できます

  2. 移動平均値からの価格偏差を用いて短期間の平均逆転機会を把握します.

  3. RSIインジケーターは 騒音の取引を効果的にフィルタリングし 頂点や死谷を追いかけるのを 避けることができます

  4. 柔軟なパラメータ調整,異なる市場環境に適応できる.

  5. 異なる好みに合わせて,ロングのみ,ショートのみ,または両方向の取引をサポートします.

リスク分析

リスクもあります:

  1. 平均逆転は,価格が移動平均値に逆戻りすることを指します.急激な価格変動が発生した場合,ストップロスのリスクが高くなります.

  2. パラメータの設定が正しくない場合,過剰な取引や機会の逃れにつながる可能性があります.

  3. 業績は市場と密接に関連しており,範囲限定および不安定な市場では劣悪です.

対策:

  1. 適切なストップロスを設定して,単一の取引損失を制御します.

  2. パラメータを徐々に最適化し リスク調整済の収益を評価する

  3. 適応力を高めるために 株式指数と組み合わせます

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

戦略は以下の側面で最適化できます.

  1. 適正なパラメータを見つけるために異なる移動平均の組み合わせをテストする.

  2. 傾向を特定し 勝率を向上させるために 他の指標を組み込むことを試してください

  3. ストップ・ロスのメカニズムを追加して最大引き上げを減らす

  4. 利益因子を改善するために 入出規則を最適化します

  5. 機械学習技術を採用して 適応性のあるパラメータを構築する

結論

HYE Mean Reversion SMA戦略は,シンプルで実用的な短期間の平均逆転戦略である.移動平均値からの価格偏差を使用して取引信号を生成し,RSI指標でノイズをフィルタリングする.良好なバックテストパフォーマンスを示した.この戦略は,異なる市場環境に適応する調整可能なパラメータで簡単に実装できる.しかし,逆転とストップロスのリスクの不確実性が注意されるべきで,異なる市場条件に適切な最適化が必要である.全体として,定量的な取引のための良い参照平均逆転戦略テンプレートを提供します.


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

// @version=4

strategy("HYE Mean Reversion SMA [Strategy]", overlay = true )
  
//Strategy inputs
source = input(title = "Source", defval = close)
tradeDirection = input(title="Trade Direction", type=input.string,
     options=["Long Only", "Short Only", "Both"], defval="Long Only") 
smallMAPeriod = input(title = "Small Moving Average", defval = 2)
bigMAPeriod = input(title = "Big Moving Average", defval = 5)
percentBelowToBuy = input(title = "Percent below to buy %", defval = 3)
percentAboveToSell = input(title = "Percent above to sell %", defval = 3)
rsiPeriod = input(title = "Rsi Period", defval = 2)
rsiLevelforBuy = input(title = "Maximum Rsi Level for Buy", defval = 30)
rsiLevelforSell = input(title = "Minimum Rsi Level for Sell", defval = 70)
     
longOK  = (tradeDirection == "Long Only") or (tradeDirection == "Both")
shortOK = (tradeDirection == "Short Only") or (tradeDirection == "Both")

// Make input options that configure backtest date range
startDate = input(title="Start Date", type=input.integer,
     defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", type=input.integer,
     defval=1, minval=1, maxval=12)
startYear = input(title="Start Year", type=input.integer,
     defval=2020, minval=1800, maxval=2100)

endDate = input(title="End Date", type=input.integer,
     defval=31, minval=1, maxval=31)
endMonth = input(title="End Month", type=input.integer,
     defval=12, minval=1, maxval=12)
endYear = input(title="End Year", type=input.integer,
     defval=2021, minval=1800, maxval=2100)
     
inDateRange = true

//Strategy calculation 
rsiValue = rsi(source, rsiPeriod)
rsiEMA   = ema(rsiValue, 5)
smallMA = sma(source, smallMAPeriod)
bigMA =  sma(source, bigMAPeriod) 
buyMA = ((100 - percentBelowToBuy) / 100) * sma(source, bigMAPeriod)[0]
sellMA = ((100 + percentAboveToSell) / 100) * sma(source, bigMAPeriod)[0]

if(crossunder(smallMA, buyMA) and rsiEMA < rsiLevelforBuy and inDateRange and longOK)
    strategy.entry("BUY", strategy.long) 

if(crossover(smallMA, bigMA) or not inDateRange)
    strategy.close("BUY")

if(crossover(smallMA, sellMA) and rsiEMA > rsiLevelforSell and inDateRange and shortOK)
    strategy.entry("SELL", strategy.short)

if(crossunder(smallMA, bigMA) or not inDateRange)
    strategy.close("SELL")



もっと