EMA RSI トレンドフォローおよびモメント戦略

作者: リン・ハーンチャオチャン開催日: 2024-03-29 16:30:42
タグ:

img

概要

Bybit EMA RSIトレンドフォロー&モメントム戦略は,指数関数移動平均値 (EMA) と相対強度指数 (RSI) を組み合わせた定量的な取引戦略である.この戦略は,市場動向を決定するために異なる期間の2つのEMAと,トレンドの妥当性を確認するためにRSIインジケーターを使用する.速いEMAがスローEMAを超越し,RSIが特定の下値を下回ると,戦略はロング信号を生成する.逆に,速いEMAがスローEMAを下回り,RSIが特定の上値を超越すると,戦略はショート信号を生成する.戦略には,Bybitアカウントレベルに基づいて異なる佣金パーセントと,リスクを効果的に管理するために組み込まれた利益とストップ損失機能も含まれている.

戦略の原則

  1. 周期がそれぞれ 90 と 300 で,高速 EMA と遅い EMA を計算します.
  2. RSI インディケーターを 5 の周期で計算します.
  3. 急速EMAが遅いEMAを横切ってRSIが45未満のときに長い信号を生成し,急速EMAが遅いEMAを横切ってRSIが85を超えると短い信号を生成する.
  4. バイビットアカウントレベルに基づいて 異なる佣金率を設定します VIP 0 の 0.075% から VIP 4 の 0.035% までです
  5. 入場料を計算して,手数料を計算します.
  6. 決まった割合 (5%と3%) を基に,得益とストップ損失の価格を計算する.
  7. 入場価格をグラフに描いて 利益線とストップ損失線をグラフに描いて
  8. 取引信号に基づいてエントリーオーダーを実行する.

戦略 の 利点

  1. 市場動向を効果的に把握するために,トレンドフォローとモメント指標を組み合わせます.
  2. リスクを効果的に管理するために,内蔵された利益とストップ損失の機能を含みます.
  3. Bybitアカウントレベルに基づいて異なる佣金パーセントを設定し,異なるユーザーと取引条件に適応します.
  4. グラフ上のエントリー価格,取利益線,ストップ損失線をグラフで表示し,取引信号の視覚的な確認を提供します.

戦略リスク

  1. EMA と RSI パラメータの選択は,すべての市場条件に適していない可能性があり,実際の状況に基づいて最適化する必要がある場合があります.
  2. 不安定な市場では,戦略は頻繁に取引信号を生成し,高い取引コストにつながる可能性があります.
  3. 利回し・ストップ・ロスの設定は,過度に保守的または攻撃的であり,個人リスクの好みに基づいて調整する必要がある場合があります.

戦略の最適化方向

  1. EMAとRSIのパラメータを最適化して異なる市場状況に適応する.これはバックテストとパラメータスキャンを通じて,最適なパラメータの組み合わせを見つけるために行うことができます.
  2. 取引シグナルの正確性を向上させるため,ボリンジャー帯,MACDなどの他の技術指標を導入する.
  3. 利潤とストップロスの設定を最適化します.例えば,トライリングストップやダイナミックストップロスの方法を使用して,利益をより良く保護しリスクを管理します.
  4. 市場変動や取引量などの要因を考慮し,取引信号をフィルターし,頻繁な取引に関連するコストを削減します.

概要

Bybit EMA RSIトレンドフォロー&モメントム戦略は,トレンドフォロー&モメントム指標を組み合わせた定量的な取引戦略である. EMAとRSIを組み合わせることで,市場のトレンドを効果的に把握することができる.この戦略には,内蔵された利益とストップ損失の機能が含まれ,Bybitアカウントレベルに基づいて佣金パーセントを設定し,リスクを効果的に管理し,異なるユーザーの取引条件に適応する.しかし,パラメータ最適化,他の技術指標の導入,利益とストップ損失の設定の最適化などの戦略の最適化にはまだ余地がある.継続的な最適化と改善により,戦略は実際の取引でより良い結果を達成することが期待される.


/*backtest
start: 2024-03-21 00:00:00
end: 2024-03-28 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// @BryanAaron

//@version=5
strategy("Bybit EMA RSI Strategy", overlay=true)

// Input parameters
fastLength = input(90, title="Fast EMA Length")
slowLength = input(300, title="Slow EMA Length")
rsiLength = input(5, title="RSI Length")
rsiUpperThreshold = input(85, title="RSI Upper Threshold")
rsiLowerThreshold = input(45, title="RSI Lower Threshold")
takeProfitPerc = input(5, title="Take Profit %")
stopLossPerc = input(3, title="Stop Loss %")
bybitAccountLevel = input.string("VIP 0", title="Bybit Account Level", options=["VIP 0", "VIP 1", "VIP 2", "VIP 3", "VIP 4"])

// Calculate moving averages
fastMA = ta.ema(close, fastLength)
slowMA = ta.ema(close, slowLength)

// Calculate RSI
rsi = ta.rsi(close, rsiLength)

// Trading conditions
longCondition = (fastMA > slowMA) and (rsi < rsiLowerThreshold)
shortCondition = (fastMA < slowMA) and (rsi > rsiUpperThreshold)

// Set commission based on Bybit account level
commissionPerc = switch bybitAccountLevel
    "VIP 0" => 0.075
    "VIP 1" => 0.065
    "VIP 2" => 0.055
    "VIP 3" => 0.045
    "VIP 4" => 0.035
    => 0.075

// Calculate entry prices with commission
var float longEntryPrice = na
var float shortEntryPrice = na

longEntryPriceWithCommission = close * (1 + commissionPerc / 100)
shortEntryPriceWithCommission = close * (1 - commissionPerc / 100)

// Calculate take profit and stop loss prices
takeProfitPrice(entryPrice) => entryPrice * (1 + takeProfitPerc / 100)
stopLossPrice(entryPrice) => entryPrice * (1 - stopLossPerc / 100)

// Plot entry prices
plotchar(longCondition, title="Long Entry Price", char="LE", location=location.belowbar, color=color.green)
plotchar(shortCondition, title="Short Entry Price", char="SE", location=location.abovebar, color=color.red)

// Draw position on the chart
longColor = color.green
shortColor = color.red
profitColor = color.new(color.green, 80)
lossColor = color.new(color.red, 80)

plotshape(longCondition and strategy.position_size > 0, title="Long Position", text="Long", location=location.belowbar, style=shape.labelup, size=size.small, color=longColor, textcolor=color.white)
plotshape(shortCondition and strategy.position_size < 0, title="Short Position", text="Short", location=location.abovebar, style=shape.labeldown, size=size.small, color=shortColor, textcolor=color.white)

if (strategy.position_size > 0)
    line.new(bar_index, longEntryPrice, bar_index + 1, longEntryPrice, color=longColor, width=2)
    
    longProfitLine = line.new(bar_index, takeProfitPrice(longEntryPrice), bar_index + 1, takeProfitPrice(longEntryPrice), color=profitColor, width=1)
    longLossLine = line.new(bar_index, stopLossPrice(longEntryPrice), bar_index + 1, stopLossPrice(longEntryPrice), color=lossColor, width=1)
    

else if (strategy.position_size < 0)
    line.new(bar_index, shortEntryPrice, bar_index + 1, shortEntryPrice, color=shortColor, width=2)
    
    shortProfitLine = line.new(bar_index, stopLossPrice(shortEntryPrice), bar_index + 1, stopLossPrice(shortEntryPrice), color=profitColor, width=1)
    shortLossLine = line.new(bar_index, takeProfitPrice(shortEntryPrice), bar_index + 1, takeProfitPrice(shortEntryPrice), color=lossColor, width=1)
    


// Entry
if (longCondition)
    strategy.entry("Long", strategy.long)
    longEntryPrice := longEntryPriceWithCommission
else if (shortCondition)
    strategy.entry("Short", strategy.short)
    shortEntryPrice := shortEntryPriceWithCommission

もっと