取引戦略をフォローする量に基づく傾向

作者: リン・ハーンチャオチャン開催日: 2024-01-29 15:04:18
タグ:

img

概要

このトレンドは,変更されたボリュームオシレーター指標に基づいたトレンドフォロー戦略である.これはボリューム移動平均を活用してボリュームシグナルの増加を特定し,エントリーまたは出口を決定する.一方,価格変動中に間違ったシグナルを避けるために価格トレンド判断を組み込む.

戦略の論理

  1. vol_length の長さを持つボリューム移動平均の vol_sum を計算し,それを vol_smooth 期間の移動平均で平らにする.
  2. vol_sum が値を超えると長信号と, vol_sum が値を下回ると短信号を生成する.
  3. 誤った信号をフィルターするには,過去方向バーでチェックされた価格傾向が上昇しているときにだけ長時間かかります.
  4. 2つの値 (threshold) と値 (threshold2) を設定します.値 (threshold2) はトレード・シグナルを生成し,値 (threshold2) はストップ・ロスの役割を果たします.
  5. ステートマシン・ロジックを通じて オープン/閉鎖オーダーを管理する.

利点分析

  1. ボリューム指標は,より正確なシグナルのために市場購入/販売力の変化を記録します.
  2. 価格動向と組み合わせることで 価格変動の際に 間違ったシグナルが 避けられます
  3. 2つの限界値でリスクを制御できます

リスク分析

  1. 価格転換点を見逃す可能性があります.
  2. 間違ったパラメータ設定は 過剰な取引や 信号の遅延につながります
  3. ストップ・ロスは,取引量のピーク時に発生する可能性があります.

パラメータを調整し,指標の計算を最適化し,他の確認を組み合わせることでリスクは軽減できます

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

  1. 市場状況に基づいてパラメータの適応最適化
  2. 波動性指数などの他の指標を組み込み,さらにシグナルを確認します.
  3. 信号の精度を向上させるための機械学習モデルを適用する研究

結論

この戦略は,価格トレンドの改善されたボリュームオシレーターを利用し,ストップ損失の2つの限界値でエントリーと出口を決定する.パラメータチューニング,シグナルフィルタリング,ストップ損失戦略の最適化スペースを持つ安定したトレンドフォローシステムである.全体的には,さらなる研究と最適化に値する実践的な価値がある.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy('Volume Advanced', default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075, currency='USD')
startP = timestamp(input(2017, "Start Year"), input(12, "Start Month"), input(17, "Start Day"), 0, 0)
end    = timestamp(input(9999, "End Year"),   input(1, "End Month"),   input(1, "End Day"),   0, 0)
_testPeriod() =>
    iff(time >= startP and time <= end, true, false)

source = close 
vol_length  = input(34, title = "Volume - Length")
vol_smooth  = input(200,title = "Volume - Smoothing")
volriselen  = input(21,  title = "Volume - Risinglength")
volfalllen  = input(13, title = "Volume - Fallinglength")
threshold   = input(1,"threshold")
threshold2  = input(1.2,step=0.1, title="Threshold 2")
direction = input(13,"amount of bars")


volsum  = sum(volume, vol_length) / (sum(volume, vol_smooth) / (vol_smooth / vol_length))


LongEntry  = (rising(volsum, volriselen) or crossover (volsum, threshold)) and close > close[direction]
ShortEntry = (rising(volsum, volriselen) or crossover (volsum, threshold)) and close < close[direction]
LongExit1  = falling (volsum,volfalllen)
ShortExit1 = falling (volsum,volfalllen)
LongExit2= (crossover(volsum, threshold2) and close < close[direction])


_state = 0
_prev = nz(_state[1])
_state := _prev

if _prev == 0
    if LongEntry
        _state := 1
        _state
    if ShortEntry
        _state := 2
        _state
if _prev == 1
    if ShortEntry or LongExit1
        _state := 0
        _state
if _prev == 2
    if LongEntry or ShortExit1
        _state := 0
        _state

_bLongEntry = _state == 1 
_bLongClose = _state == 0 

long_condition = _bLongEntry and close > close[direction]
strategy.entry('BUY', strategy.long, when=long_condition)  
 
short_condition =  _bLongClose or LongExit2
strategy.close('BUY', when=short_condition)

plot(volsum,      color = color.green,    title="Vol_Sum")
plot(threshold, color = color.fuchsia, transp=50, title="Threshold")
plot(threshold2, color=color.white, transp = 50, title="Threshold 2")

もっと