反転トレンドキャプチャとダイナミックストップロスの二重戦略


作成日: 2024-02-05 09:54:13 最終変更日: 2024-02-05 09:54:13
コピー: 0 クリック数: 558
1
フォロー
1617
フォロワー

反転トレンドキャプチャとダイナミックストップロスの二重戦略

概要

この戦略は,逆転トレンドキャプチャ戦略とダイナミックストップ戦略を組み合わせた二重戦略であり,逆転トレンドをキャプチャしながらダイナミックストップを設定してリスクを制御することを目的としています.

戦略原則

逆転トレンドを捉える戦略

この戦略は,ランダムな指標K値とD値に基づいています. 価格が2日間連続で下落し,K値がD値を超えて上昇すると買入シグナルを生成します. 価格が2日間連続で上昇し,K値がD値を下回ると売出シグナルを生成します.

ダイナミック・ストップ・ローズ戦略

この戦略は,価格の波動性と偏差に基づいて動的ストップポイントを設定する.これは,最近の一段の時間の価格の高点と低点の変動状況を計算し,偏差と組み合わせて,現在上流通道か下流通道か判断して,動的にストップポイントを設定する.これは,市場環境に応じてストップポイントを調整することができる.

この2つの戦略を組み合わせて,反転信号をキャプチャしながら,動的ストップダスを設定してリスクを制御する.

優位分析

  • 価格の逆転を捉え,逆転取引に適しています.
  • ダイナミックストップを設定し,市場状況に応じてストップポジションを調整できます.
  • 偽信号を避けるためにダブルシグナルを確認
  • リスク管理と利益の確保

リスク分析

  • 逆転の失敗のリスク.
  • パラメータ設定のリスク. パラメータ設定を誤って設定すると,戦略の効果に影響する.
  • 流動性リスク. 流動性の低い取引品種は,損失を止めることはできません.

パラメータの最適化,厳格な止損,流動性の良い品種を選択することでリスクを制御できます.

最適化の方向

  • ランダムな指標パラメータを最適化して,最適なパラメータの組み合わせを探します.
  • ストップ・パラメータを最適化して,最適のストップ位置を見つけます.
  • フィルタリング条件を増やして,波動的な市場でのポジションを避ける
  • ポジション管理モジュールを追加し,最大損失を制御する

総合的な最適化により,リスクの管理を前提に,戦略が逆転傾向をできるだけ捉えるようにする.

要約する

この戦略は,反転トレンドキャプチャとダイナミックストロップの二重戦略を組み合わせ,価格の反転点をキャプチャし,ダイナミックストロップコントロールのリスクを設定することができます.これは比較的安定したショートライン取引戦略です.継続的に監視を最適化することで,この戦略は安定した収益を得ることを期待しています.

ストラテジーソースコード
/*backtest
start: 2024-01-05 00:00:00
end: 2024-02-04 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 07/12/2020
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
//  The Kase Dev Stops system finds the optimal statistical balance between letting profits run, 
//  while cutting losses.  Kase DevStop seeks an ideal stop level by accounting for volatility (risk),
//  the variance in volatility (the change in volatility from bar to bar), and volatility skew 
//  (the propensity for volatility to occasionally spike incorrectly).
//  Kase Dev Stops are set at points at which there is an increasing probability of reversal against 
//  the trend being statistically significant based on the log normal shape of the range curve.  
//  Setting stops will help you take as much risk as necessary to stay in a good position, but not more.
//
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos

KaseDevStops(Length, Level) =>
    pos = 0.0
    RWH = (high - low[Length]) / (atr(Length) * sqrt(Length))
    RWL = (high[Length] - low) / (atr(Length) * sqrt(Length))
    Pk = wma((RWH-RWL),3)
    AVTR = sma(highest(high,2) - lowest(low,2), 20)
    SD = stdev(highest(high,2) - lowest(low,2),20)
    Val4 = iff(Pk>0, highest(high-AVTR-3*SD,20), lowest(low+AVTR+3*SD,20))
    Val3 = iff(Pk>0, highest(high-AVTR-2*SD,20), lowest(low+AVTR+2*SD,20))
    Val2 = iff(Pk>0, highest(high-AVTR-SD,20), lowest(low+AVTR+SD,20))
    Val1 = iff(Pk>0, highest(high-AVTR,20), lowest(low+AVTR,20))
    ResPrice = iff(Level == 4, Val4,
                 iff(Level == 3, Val3,
                  iff(Level == 2, Val2,
                     iff(Level == 1, Val1, Val4))))
    pos := iff(close < ResPrice , -1, 1)
    pos

strategy(title="Combo Backtest 123 Reversal & Kase Dev Stops", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthKDS = input(30, minval=2, maxval = 100)
LevelKDS = input(title="Trade From Level", defval=4, options=[1, 2, 3, 4])
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posKaseDevStops = KaseDevStops(LengthKDS, LevelKDS)
pos = iff(posReversal123 == 1 and posKaseDevStops == 1 , 1,
	   iff(posReversal123 == -1 and posKaseDevStops == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )