VWAP-RSI 超売れたCrossunder BTC ショート戦略

作者: リン・ハーンチャオチャン, 日時: 2023-12-29 14:12:54
タグ:

img

概要

これは,VWAPのRSI指標に基づいた時間枠間のBTCショート戦略である.VWAP曲線を得るために各キャンドルストックのボリューム重量平均価格 (VWAP) を計算し,その後,曲線にRSI指標を適用する.RSI指標がオーバーボートゾーンから下を横切ると,BTCにショートになる.

戦略の論理

  1. VWAP曲線を得るために各キャンドルスタイルのVWAPを計算する
  2. RSI指標をVWAP曲線に適用します. 曲線の長さは20日. 超買値が85で,超売値が30です.
  3. RSI が過買いゾーン (85) から過売りゾーン (30) に下りくると,ショートポジションを開く.
  4. 28個のキャンドルスタイクを保持した後にポジションを閉じるか,またはRSIが再過売り線 (30) を横切る場合

利点分析

  1. 実際の取引価格を反映するために,簡単な閉じる価格の代わりにVWAPを使用します.
  2. 高値で買い,低値で売るのを避けるために,RSIで過買い/過売り状態を特定する.
  3. 罠にはまらないように タイムフレームを越えて取引する
  4. 制御可能なリスク 28個のキャンドルスタイクストップ・ロスト

リスク と 解決策

  1. ブラック・スワン事件により価格が急上昇し,損失を止めることができなかった.
    • 時間枠間の取引を導入し,罠にかかったリスクを減らす
  2. 不適切なパラメータ設定,機会を簡単に逃す
    • RSI パラメータと過買い/過売りレベルをテストし最適化
  3. RSIは過剰販売領域に突入できない
    • 他の指標と組み合わせてトレンドを決定し,パラメータを柔軟に調整します

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

  1. 最適値を見つけるためにより多くのパラメータ組み合わせをテストする
  2. MACD,KD などと組み合わせて,買い過ぎ/売過ぎ状態を判断する.
  3. テストパラメータの設定は異なる資産に対して別々に設定する.
  4. ストップ・ロスのメカニズムを最適化し,波動性に基づいてストップ・ロスの範囲を設定する

概要

この戦略は,VWAPとRSIの組み合わせでBTCオーバーバイト/オーバーセール状態を特定する.タイムフレームを介して取引することで,リスクを効果的に制御することができます.戦略の論理は明確で理解しやすく,ライブ取引のためにさらなるテストと最適化に価値があります.


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


//@version=4

strategy("Soran Strategy 2 - SHORT SIGNALS", pyramiding=1, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=50, overlay=false)


// ----------------- Inputs ----------------- //

reso = input(title="Resolution", type=input.resolution, defval="")
length = input(20, title="RSI Length", type=input.integer)
ovrsld = input(30, "RSI Oversold level", type=input.float)
ovrbgt = input(85, "RSI Overbought level", type=input.float)
lateleave = input(28, "Number of candles", type=input.integer)
// lateleave : numbers of bars in overbought/oversold zones where the position is closed. The position is closed when this number is reached or when the zone is left (the first condition).

// best parameters BTCUSDTPERP M15 : 20 / 30 / 85 / 28


stratbull = input(title="Enter longs ?", type = input.bool, defval=true)
stratbear = input(title="Enter shorts ?", type = input.bool, defval=true)

stratyear = input(2020, title = "Strategy Start Year")
stratmonth = input(1, title = "Strategy Start Month")
stratday = input(1, title = "Strategy Start Day")
stratstart = timestamp(stratyear,stratmonth,stratday,0,0)


// --------------- Laguerre ----------------- //

laguerre = input(title="Use Laguerre on RSI ?", type=input.bool, defval=false)
gamma = input(0.06, title="Laguerre Gamma")

laguerre_cal(s,g) =>
    l0 = 0.0
    l1 = 0.0
    l2 = 0.0
    l3 = 0.0
    l0 := (1 - g)*s+g*nz(l0[1])
    l1 := -g*l0+nz(l0[1])+g*nz(l1[1])
    l2 := -g*l1+nz(l1[1])+g*nz(l2[1])
    l3 := -g*l2+nz(l2[1])+g*nz(l3[1])
    (l0 + 2*l1 + 2*l2 + l3)/6


// ---------------- Rsi VWAP ---------------- //

rsiV = security(syminfo.tickerid, reso, rsi(vwap(close), length))

rsiVWAP = laguerre ? laguerre_cal(rsiV,gamma) : rsiV


// ------------------ Plots ----------------- //

prsi = plot(rsiVWAP, color = rsiVWAP>ovrbgt ? color.red : rsiVWAP<ovrsld ? color.green : color.white, title="RSI on VWAP", linewidth=1, style=plot.style_line)
hline = plot(ovrbgt, color = color.gray, style=plot.style_line)
lline = plot(ovrsld, color = color.gray, style=plot.style_line)
fill(prsi,hline, color = rsiVWAP > ovrbgt ? color.red : na, transp = 30)
fill(prsi,lline, color = rsiVWAP < ovrsld ? color.green : na, transp = 30)


// ---------------- Positions: only shows the Short and close shoret positions --------------- //

timebull = stratbull and time > stratstart
timebear = stratbear and time > stratstart


strategy.entry("Short", false, when = timebear and crossunder(rsiVWAP, ovrbgt), comment="")
strategy.close("Short", when = timebear and crossunder(rsiVWAP, ovrsld)[lateleave] or crossover(rsiVWAP, ovrsld), comment="")

もっと