
この戦略は,RSI,MACD,および移動平均を利用した組み合わせ戦略である.これは,RSIの超買い超売り信号,MACDの感受性,移動平均の指標効果を統合して,入札のタイミングを判断する.
この戦略は,以下の4つの条件を考慮して,多額の入札を決定します.
次の2つの出場条件が満たされた場合,戦略は平仓を停止します.
この戦略は,収益の引き戻しの時に,損失を一時的に止めて,大きな損失を回避します.
この戦略の最大の利点は,各指標の優位性を発揮する指標の組み合わせです.
この戦略には以下の2つのリスクがあります.
撤回リスクが高い.移動平均などのトレンド型策略の最大のリスクは,市場の逆転がもたらす大きな撤回である.ポジションの規模を低くし,ストップ損失設定を積極的に制御することによって撤回することができる.
参数最適化が難しい.多指標組合せ戦略の参数設定と最適化が難しい.ステップ進法,遺伝的アルゴリズムなどの参数最適化方法を使用して最適な参数を決定することができる.
この戦略は,以下の点で改善できる:
追加条件を追加し,偽信号をさらにフィルターします.例えば,取引量指標,変動率指標などと組み合わせます.
異なる品種のパラメータ設定の違いをテストする.より多くの品種にパラメータを調整する.
移動平均のパラメータ設定を最適化する. 異なる長さのパラメータの差異をテストする.
市場環境に応じてスイッチする異なるパラメータの組み合わせを採用した.
この戦略は,全体として,典型的な最適化された移動平均とトレンド追跡戦略である.それは,MACD,RSIなどの複数の主流指標の優位性を吸収し,市場への入場時間と止損の判断においてユニークである.次のステップは,パラメータ最適化,リスク管理などの多くの側面から改善され,戦略パラメータをより頑丈に,より多くの品種に適合させ,より高い安定性を得ることができる.
/*backtest
start: 2022-12-29 00:00:00
end: 2024-01-04 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Improved RSI MACD Strategy with Moving Averages", overlay=true)
// Inputs
src = input(close, title="RSI Source")
// RSI Settings
lengthRSI = input.int(14, minval=1)
// Stop Loss Settings
stopLossPct = input.float(0.09, title="Stop Loss Percentage")
takeProfitPct = input.float(0.15, title="Take Profit Percentage")
// MACD Settings
fastlen = input(12)
slowlen = input(26)
siglen = input(9)
// Strategy Settings
longEntry = input(0, title="Long Entry Level")
exitLevel = input(0, title="Exit Level")
// EMA Settings
emaShortLength = input(8, title="Short EMA Length")
emaLongLength = input(21, title="Long EMA Length")
atrMultiplier = input.float(2, title="atrMultiplier")
atrLength = input.int(20, title="atrLength")
// Indicators
rsi1 = ta.rsi(src, lengthRSI)
[macd, signal, hist] = ta.macd(src, fastlen, slowlen, siglen)
// Calculate EMAs
emaShort = ta.ema(src, emaShortLength)
emaLong = ta.ema(src, emaLongLength)
// Calculate ATR
atr = ta.atr(atrLength)
// Variables
var bool canEnterLong = na
// Strategy conditions
longCondition = hist > longEntry and rsi1 > 50 and emaShort > emaLong and close > emaLong + atrMultiplier * atr
// Entries and Exits
if hist < exitLevel and emaShort < emaLong
canEnterLong := true
strategy.close("Long")
// Store last entry price
var lastEntryPrice = float(na)
var lastEntryPrice2 = float(na)
if longCondition
strategy.entry("Long", strategy.long)
canEnterLong := false
lastEntryPrice := close
if lastEntryPrice < close
lastEntryPrice := close
// Calculate Stop Loss and Take Profit Levels based on last entry price
stopLossLevel = lastEntryPrice * (1 - stopLossPct)
// Check for stop loss and take profit levels and close position if triggered
if (strategy.position_size > 0)
last_buy = strategy.opentrades[0]
if (close < stopLossLevel)
strategy.close("Long", comment="Stop Loss Triggered")
if (close * (1 - takeProfitPct) > strategy.opentrades.entry_price(strategy.opentrades - 1) )
strategy.close("Long", comment="Take Profit Triggered")