変動率取引戦略

作者: リン・ハーンチャオチャン, 日時: 2023-09-28 11:26:44
タグ:

概要

この戦略は,買い/売るシグナルを決定するために,時間の変化率を計算します.これは,トレーダーが短期的な価格変動の機会を把握するのに役立ちます.

戦略の論理

この戦略は主に以下の指標に基づいています

  1. 短期トレンドを測定するために,簡単な移動平均値 (デフォルト14日)
  2. 遅い単純な移動平均値 (デフォルト100日):長期トレンドを測定する
  3. 参照の単純な移動平均値 (デフォルト30日):全体的な方向性を決定する
  4. 変動率:回顧期間の最高/最低価格 (デフォルト12バー) をベースに計算し,価格変動の大きさを判断する.

特別入国規則:

  1. 基準SMAを下回る価格
  2. 前もって設定されたROCの低値を超えたROC (デフォルト2.3%)
  3. 急速なSMA上昇と緩やかなSMA低下が,潜在的なクロスオーバーを示唆する

特別出口規則:

  1. 基準 SMA を上回る価格
  2. ROCは,前もって設定されたROCの高値を超えている (デフォルト4.7%)
  3. 3つの連続した上昇バー
  4. 現金 > 0
  5. 遅いSMAより速いSMA

ポジションサイズは,レバレッジに関する総資本の割合 (デフォルト96%).

利点分析

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

  1. ROC を使って振動を検出することで,上下向きの動きを把握し,より高いリターンを得ることができます.

  2. 速い/遅いSMAを組み合わせることで,低点/高点をより正確に識別できます.

  3. 参照SMAは,短期間の騒音から注意をそらすことを避けるための全体的な方向性を提供します.

  4. ストップロスの後を追うことは 利益を固定し 下行リスクを軽減します

  5. ポジションのサイズから利息は利益を増大させます

全体的に,この戦略はROC,SMAおよび他のツールを使用して,価格変動を有効に活用します.不安定な市場で良い結果を達成することができます.

リスク分析

この戦略には次のリスクもあります

  1. 誤ったROCおよびSMAパラメータは,見逃した信号または悪い取引を引き起こす可能性があります.異なる市場のために最適化が必要です.

  2. 過剰なポジションサイズはリスクを増やします. オーダーパーセントはテストして調整する必要があります.

  3. トレイリングストップロスは,不安定な市場で早めに終了する可能性があります.ストップロスの割合は調整できます.

  4. トレンドフィルターとリスク管理を 組み込むべきです

  5. バックテスト 過適性リスク 安定性は市場間でのライブ取引によって確認されるべきです

リスクはパラメータの最適化,ポジションサイズ,ストップ損失調整,強度テストなどによって管理できます.

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

戦略は以下の点で改善できる:

  1. 波動性やボリュームなどの他の技術指標を追加して 信号の精度を向上させます

  2. 取引頻度を減らすことで取引数を最適化し,ウィップソーの影響を最小限に抑える.

  3. 重要な価格レベルを 突破する技術を取り入れます

  4. マシン学習を使って パーマータを自動最適化します

  5. 異なる市場や時間枠で 安定性をテストする

  6. 株や外為などの異なる商品の特殊なパラメータを調整します

  7. リアルタイムでの結果に基づいて信号とリスク制御を継続的に改良する.

概要

この戦略は,ROCとSMA分析を使用して短期振動の周りの取引機会を特定する.迅速な変動を資本するのに役立ちますが,適切なリスク制御も必要です.微調整パラメータ,ポジションサイズ,ストップ損失および強度テストは,その安定性と適応性を向上させることができます.この戦略は定量化取引のための参照テンプレートとして機能しますが,異なる市場向けにカスタマイズする必要があります.


/*backtest
start: 2022-09-21 00:00:00
end: 2023-09-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// @version=4
// Author: Sonny Parlin (highschool dropout)
// Best if run on 5m timeframe
strategy(shorttitle="ROC+Strategy", title="Rate of Change Strategy",
                                      overlay=true,  currency=currency.USD,
                                      initial_capital=10000)

// Inputs and variables
ss = input(14, minval=10, maxval=50, title="SMA Fast (days)")
ff = input(100, minval=55, maxval=200, title="SMA Slow (days)")
ref = input(30, minval=20, maxval=50, title="SMA Reference (days)")
lowOffset = input(0.023, "ROC Low (%)", minval=0, step=0.01)
highOffset = input(0.047, "ROC High (%)", minval=0, step=0.01)
orderStake = input(0.96, "Order Stake (%)", minval=0, step=0.01)
lookback = input(12, "Lookback Candles", minval=1, step=1) 

// SMA
smaFast = sma(close, ss)
smaSlow = sma(close, ff)
smaRef = sma(close, ref)
ROC = (max(close[lookback],close) - min(close[lookback],close)) / max(close[lookback],close)

// Set up SMA plot but don't show by default
plot(smaFast, "smaFast", color=#00ff00, display = 0)
plot(smaSlow, "smaSlow", color=#ff0000, display = 0)
plot(smaRef, "smaRef", color=#ffffff, display = 0)

// The buy stratey:
// Guard that the low is under our SMA Reference line 
// Guard that the rate of change over the lookback period is greater than our 
// ROC lowOffset %, default is 0.023. (low < smaRef) and (ROC > lowOffset)
// SMA fast is on the rise and SMA slow is falling and they are very likely
// to cross. (rising(smaFast,1)) and (falling(smaSlow, 1)) 
enterLong = (low < smaRef) and (ROC > lowOffset) and (rising(smaFast,1)) and (falling(smaSlow,1)) 

// The sell Strategy:
// Guard that close is higher than our SMA reference line and that the rate of 
// change over the lookback period is greater than our highOffset %, default
// is 0.047. (close > smaRef) and (ROC > highOffset)
// Guard that close has risen by 3 candles in a row (rising(close,3)) 
// Guard that we currently have profit (strategy.openprofit > 0)
// Guard that SMA fast is higher than smaSlow (smaFast > smaSlow)
// If it keeps going up past our close position the trailing stoploss will kick in!
enterShort = (close > smaRef) and (ROC > highOffset) and (rising(close,3)) and (strategy.openprofit > 0) and (smaFast > smaSlow)

// Order size is based on total equity
// Example 1:
// startingEquity = 2000
// close = 47434.93
// orderStake = 0.45
// (2,000 × orderStake) / close = orderSize = 0.0189733599 = approx $900

// Example 2:
// startingEquity = 2000
// close = 1.272
// orderStake = 0.45
// (startingEquity × orderStake) / close = orderSize = 707.5471698113 = approx $900
orderSize = (strategy.equity * orderStake) / close

// Trailing Stoploss
// I'm using 2.62 as my default value, play with this for different results.
longTrailPerc = input(title="Trailing Stoploss (%)",
     type=input.float, minval=0.0, step=0.1, defval=3.62) * 0.01
     
longStopPrice = 0.0

longStopPrice := if (strategy.position_size > 0)
    stopValue = close * (1 - longTrailPerc)
    max(stopValue, longStopPrice[1])
else
    0

if (enterLong)
    strategy.entry("Open Long Position", strategy.long, orderSize, when=strategy.position_size <= 0)
    
if (enterShort)
    strategy.exit(id="Close Long Position", stop=longStopPrice)


//plot(strategy.equity)

もっと