RSI MACDクロスオーバー ダブルMA追跡戦略

作者: リン・ハーンチャオチャン開催日:2023年10月23日17時44分
タグ:

img

概要

この戦略は,RSI指標,MACD指標,およびダブル移動平均を組み合わせて,トレンド追跡および波動性市場のポジショニング効果を達成する.それは,RSI指標を使用して,過買いおよび過売状態を判断し,MACDを使用して,迅速かつ遅いMAクロスオーバーでエントリーおよび出口点を決定し,トレンド中に騒々しい取引機会をフィルタリングするダブルMAを使用します.

戦略の論理

  1. 過剰購入と過剰販売のRSI指標を計算する
  • 価格変動の上昇傾向と下落傾向を計算する

  • 価格変化に基づいてRSIを計算する

  • 過剰購入と過剰販売のレベルを決定する

  1. クロスオーバーのMACDを計算する
  • 速いMA,遅いMA,信号線を計算する

  • 黄金の十字架で長く入って 死の十字架で出る

  • クロスオーバーの状況を描画する

  1. 2つのMAフィルターを導入する
  • 移動平均を計算する

  • 急速なMAが遅いMAを上回る場合にのみ取引を検討する

  • 騒音をフィルタリングして,トレンドに従ってください

  1. 入国指標を組み合わせる
  • RSI,MACDとダブルMAをフィルターしたエントリー信号

  • 戦略の正確性と安定性を向上させる

利点分析

  • 複数の指標を組み合わせることで,正確性が向上します

  • トレンドフォローはノイズをフィルタリングし,安定性を向上させる

  • RSIは潜在的な逆転点を発見します

  • MACDクロスオーバーは,簡単なエントリーと出口信号を提供します.

  • ダブルMAはほとんどの反トレンド取引を削除します.

  • 簡単なパラメータで理解しやすい 学習に便利

リスク分析

  • 複数の指標に過度に適合するリスク

  • 2回MMAは柔軟性を犠牲にして チャンスを逃すかもしれない

  • RSI と MACD パラメータ は 慎重 に 選べる 必要 が あり ます

  • シンボルに基づいてストップ損失に注意してください

  • パラメータの定期的な再調整が必要です

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

  • 異なるシンボルのRSIパラメータを調整する

  • より良い追跡のために,二重MA期間を最適化

  • 単一の取引損失を制御するためにストップロスを追加する

  • コンボを豊かにするためにより多くの指標を組み込む

  • オートチューニングのための適応パラメータモデルを開発

概要

この戦略は,RSI,MACDとダブルMAを組み合わせて,トレンドを特定し,追跡し,複数の層を通してシグナルをフィルタリングする.これは初心者にとって学び,改善するのに非常に適しています.その利点は,そのシンプルさと適応性にあります.パラメータの細かな調整により,立派な安定したリターンを得ることができます.次のステップには,より多くの指標を追加し,異なる市場環境のために自動最適化するための適応パラメータモデルを開発することが含まれます.


/*backtest
start: 2023-09-22 00:00:00
end: 2023-10-22 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3

// strategy(title="RSI MACD", precision = 6, pyramiding = 1, default_qty_type = strategy.percent_of_equity, default_qty_value = 99, commission_type = strategy.commission.percent, commission_value = 0.25, initial_capital = 1000)

// Component Code Start
// Example usage:
// if testPeriod()
//   strategy.entry("LE", strategy.long)
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(01, "Backtest Start Month")
testStartDay = input(2, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2019, "Backtest Stop Year")
testStopMonth = input(7, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)

testPeriod() => true
// Component Code Stop

//standard rsi template
src = ohlc4, len = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=#87ff1a)
band1 = hline(80)
band = hline(50)
band0 = hline(20)
fill(band1, band0, color=purple, transp=90)

//macd

fast_length = input(title="Fast Length",  defval=9)
slow_length = input(title="Slow Length",  defval=72)
signal_length = input(title="Signal Length",  defval=9)

fast_ma = sma(rsi, fast_length) 
slow_ma = sma(rsi, slow_length) 
shortma = sma(ohlc4, fast_length)
longma = sma(ohlc4, slow_length)
controlmainput = input(title = "Control MA", defval = 234)
controlma = sma(ohlc4, controlmainput)
macdx = fast_ma - slow_ma
signalx = sma(macdx, signal_length)
hist = macdx - signalx
ma_hist = shortma - controlma
macd = macdx + 50
signal = signalx + 50

plot(macd,"macd", color = fuchsia)
plot(hist,"hist", style = histogram, color = fuchsia)
//plot(ma_hist,"ma hist", style = histogram, color = orange)
plot(signal,"signal", color = white)

//input
control_buy_toggle = input(true, "Buy on crossover control MA?", type = bool)
buy_on_control = control_buy_toggle == true? true : false

//conditions
buy = buy_on_control == true? ma_hist > 0 and shortma > longma and crossover(macd,signal) or crossover(shortma, controlma) : ma_hist > 0 and shortma > longma and crossover(macd,signal)
sell = ma_hist > 0 and shortma > longma and crossunder(macd,signal)
stop = crossunder(shortma, longma) or crossunder(shortma, controlma)

plotshape(buy,"buy", shape.triangleup, location.bottom, green, size = size.tiny)
plotshape(sell,"sell", shape.triangledown, location.bottom, red, size = size.tiny)
plotshape(stop,"stop",shape.circle,location.bottom, white, size = size.tiny)

if testPeriod()
    strategy.entry("buy", true, when = buy, limit = close)
    strategy.close("buy", when = sell)
    strategy.close("buy", when = stop)
    



もっと