ボリューム価格指標 バランスのとれた取引戦略

作者: リン・ハーンチャオチャン, 日付: 2023-11-24 14:35:13
タグ:

img

概要

この戦略は,マルチタイムフレームのボリューム価格指標取引戦略である.潜在的なロング・シグナルを識別するために,相対強度指数 (RSI),平均真差 (ATR),シンプル・ムービング・平均 (SMA) およびカスタム・ボリューム価格条件を包括的に利用する.特定のオーバーセール,ボリューム価格クロスオーバー,価格ブレイクおよび他のエントリー条件が満たされると,この戦略はロングポジションを確立する.また,取引ごとにリスク・リターン比率を制御するためにストップ・ロストと利益レベルを設定する.

戦略の論理

この戦略の主なポイントは以下の通りです.

  1. RSIが過売値を下回り,過去10バーで過売値を維持すると,過売信号とみなされます.
  2. ボリューム価格条件の複数のセットが定義され,ボリューム価格指標のロング信号を起動するために,これらの条件はすべて同時に満たさなければなりません.
  3. 閉じる価格が13期SMAを突破すると,これは価格ブレイクシグナルとみなされます.
  4. ATRの小さな周期がATRの大きな周期よりも低いことも,長い信号に貢献しています
  5. 戦略は上記のすべての信号を組み合わせて,最終的な長引入決定を下す.

この戦略では,RSI指標の長さと過剰販売パラメータを設定し,これらのパラメータに基づいてRSI値を計算します.RSIが連続した複数のバーで過剰販売レベルを下回ると,過剰販売信号が起動します.

さらに,戦略は3つのボリュームスロージルを定義し,異なる時間枠からのデータに基づいて複数のボリューム価格条件を設定する.例えば,90期間のボリューム値は49期間の1.5倍以上である.これらのボリューム価格条件が同時に満たされると,ボリューム価格指標は長い信号を生成する.

価格方面では,戦略は13期SMAを計算し,価格がSMAを突破して以来のバーの数を数えます.価格がSMAを突破してブレイク後のバー数が5未満の場合,価格ブレイクシグナルとみなされます.

ATR 期間パラメータについては,この戦略では,ATR の 5 の小さな期間と 14 の大きな期間を指定します.小期間 ATR が大きな期間 ATR より低い場合,市場の変動が下向きに加速していることを示し,長い信号に貢献します.

最後に,戦略は,過剰販売,ボリューム価格,価格ブレイクアウト,ATR指標を含む上記のすべてのエントリー基準を考慮します.これらのすべての条件が同時に満たされると,最終的なロング・シグナルが起動し,ロング・ポジションが確立されます.

利点

この戦略には以下の利点があります.

  1. 複数のタイムフレームのボリューム価格条件判断は精度を向上させる. 戦略は,単一のタイムフレームではなく,異なるタイムフレームで複数のボリューム価格データのセットを評価することで,取引量の集中をより正確に判断することができます.

  2. 過売量 + 価格量 + 価格ブレイクという三重確認メカニズムは,信頼性の高いエントリー信号を保証する.過売量条件はエントリーの基本タイミングを提供し,ボリューム価格および価格指標からの追加的な確認は,長い信号の信頼性をさらに保証する.

  3. ストップ・ロスト・アンド・テイク・プロフィートメカニズムは,取引ごとにリスクを厳格に制御する.ストップ・ロスト・アンド・テイク・プロフィートのパラメータは,取引ごとにリスクを合理的に制御しながら利益を最大化するために,個人のリスク欲求に基づいて調整することができます.

  4. 複数の指標を統合することで,強度が向上します.一部の指標が失敗または機能不全した場合でも,戦略は判断のために他の指標に依存し,一定の回復力を確保できます.

リスク と 対策

この戦略にはいくつかのリスクもあります:

  1. パラメータ構成リスク.指標のパラメータ設定は判断に直接影響し,不適切なパラメータは取引信号のバイアスにつながる可能性があります.合理的なパラメータ値は慎重に検証する必要があります.

  2. 利益の可能性が限られている.集団判断のための複数の指標を統合する戦略として,その信号は時間単位あたり比較的少ない取引でより保守的である傾向があり,したがって利益の可能性にはいくつかの制約がある.

  3. インディケーターの差異リスク.あるインディケーターが長い信号を出し,他のインディケーターが短い信号を出す場合,戦略は最適な決定を決定することはできません.インディケーター間のそのような潜在的な差異は事前に特定され解決する必要があります.

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

この戦略は,次の側面でさらに最適化できます.

  1. 判断を助けるための機械学習モデルを組み込む. モデルは,手動で定義されたパラメータを動的に調整するために,ボリューム価格と波動性の特徴について訓練することができます.

  2. トレーリング・ストップ・テイク・プロフィート,部分的なテイク・プロフィートなど,収益戦略の洗練を向上させ,利益損失を防ぐ一方で,取引あたりの利益をさらに増加させる.

  3. オーダーブックデータを組み込むことを評価する.価格とボリュームチャートデータに加えて,オーダーブックデータは補完的な参照信号を提供するために深度流動性分布情報も明らかにする.

  4. 他の指標とのテスト組み合わせ.この戦略は主にRSI,ATR,SMAなどの指標を使用する.ボリンジャーバンドやKDJなどの他の指標も組み合わせて取引信号のソースを多様化し最適化することができます.

結論

この戦略は,RSI,ATR,SMA,カスタム・ボリューム価格条件を含む指標の組み合わせを使用して,潜在的なロングエントリー機会を特定する.マルチタイムフレーム・ボリューム価格評価,トリプル確認メカニズム,ストップ・ロスト/テイク・プロフィートリスク制御などの利点があります.しかし,パラメータ構成,制限された利益の可能性などのリスクも注意する必要があります.将来,この戦略は,機械学習増強,より洗練されたテイク・プロフィートデザイン,オーダーブックデータの組み込み,および拡張された指標組み合わせによってさらに強化することができます.


/*backtest
start: 2023-10-24 00:00:00
end: 2023-11-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © Kimply_Tr
//@version=5

// Strategy settings and parameters
strategy(title='Volume ValueWhen Velocity', overlay=true)

// Define the stop-loss and take-profit percentages for the long strategy
long_stoploss_value = input.float(defval=3, title='Stop-Loss (SL) %', minval=0, group='▶ Stop Loss/Take Profit => Long-Strategy', inline='2')
long_stoploss_percentage = close * (long_stoploss_value / 100) / syminfo.mintick  // Calculate long stop-loss percentage
long_takeprofit_value = input.float(defval=2, title='Take-Profit (TP) %', minval=0, group='▶ Stop Loss/Take Profit => Long-Strategy', inline='2')
long_takeprofit_percentage = close * (long_takeprofit_value / 100) / syminfo.mintick  // Calculate long take-profit percentage

// Define parameters related to ValueWhen occurrences
occurrence_ValueWhen_1 = input.int(title='occurrence_ValueWhen_1', defval=1, maxval=100, step=1, group="▶ ValueWhen",tooltip ="Its value must be smaller than (occurrence_ValueWhen_2)")  
occurrence_ValueWhen_2 = input.int(title='occurrence_ValueWhen_2', defval=5, maxval=100, step=1, group="▶ ValueWhen" ,tooltip="Its value must be greater than (occurrence_ValueWhen_1)")
distance_value=input.int(title='distance_value_occurrence', defval=170, maxval=5000, step=1, group="▶ ValueWhen" ,tooltip="It indicates the minimum distance between the occurrences of 1 and 2, i.e. the difference between the occurrences of 1 and 2 is greater than (distance_value_occurrence)")

// Define RSI-related parameters
rsi_over_sold = input.int(defval=60, minval=1, title='Oversold Level', group='▶ RSI',inline ='2')  // Input for oversold level in RSI
rsi_length = input.int(defval=40, minval=1, title='RSI Length', group='▶ RSI',inline ='2')  // Input for RSI length
rsi = ta.rsi(close, rsi_length)  // Calculate RSI

// Define volume thresholds
volume_threshold1 = input.float(title='volume_threshold_1', defval=0.5, maxval=10, step=0.1, group="▶ Volume")  
volume_threshold2 = input.float(title='volume_threshold_2', defval=0.4, maxval=10, step=0.1, group="▶ Volume")  
volume_threshold3 = input.float(title='volume_threshold_3', defval=0.62, maxval=10, step=0.1, group="▶ Volume")  

// ATR (Average True Range)
// Define ATR parameters
atr_small = input.int(title='ATR_Small', defval=5, maxval=500, step=1, group="▶ Atr",inline ='2') 
atr_big = input.int(title='ATR_Big ', defval=14, maxval=500, step=1, group="▶ Atr",inline ='2') 

atr_value3 = ta.atr(15)  // Calculate ATR value 3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Date Range
// Define the date range for back-testing
start_date = input.int(title='Start Day', defval=1, minval=1, maxval=31, group='▶ Time-Period for Back-Testing', inline='1')  // Input for start day
end_date = input.int(title='until Day', defval=1, minval=1, maxval=31, group='▶ Time-Period for Back-Testing', inline='1')  // Input for end day
start_month = input.int(title='Start Month', defval=7, minval=1, maxval=12, group='▶ Time-Period for Back-Testing', inline='2')  // Input for start month
end_month = input.int(title='until Month', defval=1, minval=1, maxval=12, group='▶ Time-Period for Back-Testing', inline='2')  // Input for end month
start_year = input.int(title='Start Year', defval=2022, minval=1800, maxval=3000, group='▶ Time-Period for Back-Testing', inline='3')  // Input for start year
end_year = input.int(title='until Year', defval=2077, minval=1800, maxval=3000, group='▶ Time-Period for Back-Testing', inline='3')  // Input for end year
in_date_range = time >= timestamp(syminfo.timezone, start_year, start_month, start_date, 0, 0) and time < timestamp(syminfo.timezone, end_year, end_month, end_date, 0, 0)  // Check if the current time is within the specified date range
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
was_over_sold = ta.barssince(rsi <= rsi_over_sold) <= 10  // Check if RSI was oversold in the last 10 bars
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
getVolume(symbol, bar) =>
    request.security(syminfo.tickerid, "D", volume)[bar]  // Function to get volume data for a specific symbol and bar

getVolume2(symbol, bar) =>
    request.security(syminfo.tickerid, "39", volume)[bar]  // Function to get volume data for a specific symbol and bar 2
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

firstCandleColor1 = request.security(syminfo.tickerid, "D", close[2] > open[1] ? 1 : 0)
firstCandleColor2 = request.security(syminfo.tickerid, "1", close[2] > open[0] ? 1 : 0)
firstCandleColor3 = request.security(syminfo.tickerid, "W", close[1] > open[1] ? 1 : 0)

firstCandleColor= ((firstCandleColor1+firstCandleColor2)) > firstCandleColor3 ? 1 : 0

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sma = ta.sma(close, 13)  // Calculate the simple moving average (SMA) of the close price over 13 periods
numCandles = ta.barssince(close > sma)  // Count the number of candles since the close price crossed above the SMA
atr1=request.security(syminfo.tickerid, "30", ta.atr(atr_small)<ta.atr(atr_big))  // Get the ATR value for the specific security and timeframe (30 minutes) and check if ATR_small is less than ATR_big

prevClose = ta.valuewhen(close > sma, close, occurrence_ValueWhen_1)  // Get the close price when it first crosses above the SMA based on occurrence_ValueWhen_1
prevCloseBarsAgo = ta.valuewhen(close > sma, close, occurrence_ValueWhen_2)  // Get the close price when it first crosses above the SMA based on occurrence_ValueWhen_2
prevCloseChange =  (prevCloseBarsAgo - prevClose )  // Calculate the change in the close price between the occurrences of crossing above the SMA

atrval=(atr_value3>140) or (atr_value3 < 123)  // Check if atr_value3 is either greater than 140 or less than 123

Condition =  getVolume(syminfo.tickerid, 90) > volume_threshold1 * getVolume(syminfo.tickerid, 49)   and getVolume(syminfo.tickerid, 110) > volume_threshold3 * getVolume(syminfo.tickerid, 49)  and getVolume2(syminfo.tickerid, 30) > volume_threshold2 * getVolume2(syminfo.tickerid, 55) and getVolume2(syminfo.tickerid, 7) > volume_threshold2 * getVolume2(syminfo.tickerid, 3)  // Check multiple volume conditions

buy_signal=Condition  and atrval and firstCandleColor==0 and  was_over_sold and  prevCloseChange> distance_value and atr1 and  numCandles<5  // Determine if the buy signal is generated based on various conditions

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Long Strategy
// Enter long position if the buy signal conditions are met and within the specified date range
if buy_signal and in_date_range
    strategy.entry('Long', strategy.long, alert_message='Open Long Position')  // Enter long position
    strategy.exit('Long SL/TP', from_entry='Long', loss=long_stoploss_percentage, profit=long_takeprofit_percentage, alert_message='Your SL/TP-Limit for the Long-Strategy has been activated.')  // Exit long position with stop-loss and take-profit




もっと