移動平均RSI 仮想通貨関連トレンド戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-12 10:26:21
タグ:

img

概要

これは,移動平均値,相対強度指数 (RSI) と市場相関を組み合わせて,中期から長期間の価格傾向を特定し,トレンドが始まるときにポジションを確立し,トレンドに沿ってピラミッドを設定し,トレンド逆転信号が検出されたときに利益を得る長期間の仮想通貨のトレンドフォロー戦略です.

戦略の論理

この戦略は主に3つの指標に基づいています.

  1. 相対強度指数 (RSI): 過買い・過売状態を特定する.51を超えると過買い・49を下回ると過売とみなされる.

  2. シンプル・ムービング・アベア (SMA): 9日間のSMAは,トレンド方向性を決定するための閉値です.

  3. 市場相関: 取引手段との相関を計算する基準として,暗号資本総額を使用し,信号品質を改善するために元の棒を相関棒に置き換える.

具体的には,取引規則は次のとおりです.

ロングエントリー:RSIが51を超え,閉じる価格は9日SMAを超えると.

ショートエントリー:RSIが49を下回り,閉じる価格は9日SMAを下回る.

長期取引では1%/0.1%,ショート取引では0.05%/0.03%.

取引期間を制限する時間条件もあります

利点分析

  1. トレンドと過剰購入/過剰販売の指標を組み合わせることで 中長期の傾向を効果的に追跡できます

  2. 市場の相関は信号の質を向上させ 誤った傾向を回避します

  3. 合理的な利益とストップロスは 損失を増やすのを防ぐ.

  4. 調整可能な取引期間は,異なる市場状況に適応します.

リスク分析

  1. 短期の変動市場では効果がない.

  2. ベンチマークの逆転は,取引手段の遅れの終了を引き起こす可能性があります.

  3. ロング/ショートだけをする場合 逆転の機会を逃す可能性があります

解決策:

  1. 短期指標を追加します.例えば,市場レジムの検出とストップのためのKC,BOLL.

  2. 適切なタイミングで脱退するためのベンチマーク分析を強化する.

  3. 逆転を把握するために両面の楽器を取引する.

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

  1. 市場統計に基づいて,RSI,SMA,利益取得/ストップ損失のパラメータ調整

  2. 比較値と取引の組み合わせを評価し,より高い相関性と流動性を有します.

  3. 他の戦略と組み合わせて 中期から長期の投資に使う.

結論

この戦略は,トレンド,モメンタム,および相関分析を効果的に組み合わせ,取引決定を改善する.適切なパラメータチューニングと複合の使用は,その安定性と収益性を大幅に向上させることができます.長期保持期間は,暗号市場の高変動性および正確に捕捉するのが難しい性質にも適しています.


/*backtest
start: 2022-12-04 00:00:00
end: 2023-12-10 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/
// © exlux99

//@version=4
strategy(title = "Crypto swing correlation", overlay = true,  pyramiding=1,initial_capital = 1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.03)

//time
fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2010, title = "From Year", minval = 1970)
 //monday and session 
// To Date Inputs
toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2021, title = "To Year", minval = 1970)

startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true

useCorrelation    = input(true, title="Use Correlation candles?")

symbol = input("BTC_USDT:swap", type=input.symbol)

haClose = useCorrelation ? security(symbol, timeframe.period, close) : close
haOpen  = useCorrelation ? security(symbol, timeframe.period, open) : open
haHigh  = useCorrelation ? security(symbol, timeframe.period, high) : high
haLow   = useCorrelation ? security(symbol, timeframe.period, low) : low

length = input( 50 )
overSold = input( 51 )
overBought = input( 49 )

s = input(title="Source", defval="haClose", options=["haClose", "haOpen", "haHigh", "haLow"])

price = s == "haClose" ? haClose: s == "haOpen" ? haOpen : s == "haHigh" ? haHigh : s == "haLow" ? haLow : na

len = input(8, "Length Moving average", minval=1)
src = price
ma = sma(src, len)


vrsi = rsi(price, length)
long = crossover(vrsi, overSold) and time_cond and price > ma
short = crossunder(vrsi, overBought) and time_cond and price < ma


takeProfit_long=input(1.0, step=0.005)
stopLoss_long=input(0.1, step=0.005)
takeProfit_short=input(0.05, step=0.005)
stopLoss_short=input(0.03, step=0.005)

strategy.entry("long",1,when=long)
strategy.entry("short",0,when=short)

strategy.exit("short_tp/sl", "long", profit=close * takeProfit_long / syminfo.mintick, loss=close * stopLoss_long / syminfo.mintick, comment='LONG EXIT',  alert_message = 'closeshort')
strategy.exit("short_tp/sl", "short", profit=close * takeProfit_short / syminfo.mintick, loss=close * stopLoss_short / syminfo.mintick, comment='SHORT EXIT',  alert_message = 'closeshort')


もっと