双方向移動平均反転戦略


作成日: 2023-11-21 11:28:27 最終変更日: 2023-11-21 11:28:27
コピー: 0 クリック数: 586
1
フォロー
1617
フォロワー

双方向移動平均反転戦略 投稿した記事の内容をご覧下さい.

概要

この戦略は,123形状逆転戦略と熊力の指標戦略を総合的に適用し,両者が同方向の多価または短価シグナルが現れたときに取引シグナルを生成し,突破逆転取引戦略に属します.

戦略原則

この戦略は2つの部分から構成されています.

  1. 123形反転戦略

閉盘価格が2日連続で下落した後,3日連続で閉盘価格が上昇突破し,低位ストック指標が低位反発時に買入シグナルを生じるとき;閉盘価格が2日連続で上昇した後,3日連続で閉盘価格が下落突破し,高位ストック指標が高位反転時に売りシグナルを生じるとき.

  1. 熊力の指標戦略

熊力の指標は多空力の対比を反映し,指標が設定された出売境界線より大きいときに出売信号を生じ,指標が設定された買取境界線より小さいときに買取信号を生じます.

合成信号では,両者が同向信号を出すと,実際の取引信号が生成される.

戦略的優位性

  1. 反転信号と指標フィルタを組み合わせて,偽突破を回避し,信号品質を向上させる.

  2. 複数のタイムサイクルが適用され,異なる市場環境に対応する柔軟性があります.

  3. 構成要素策略は単独で使用できるが,組み合わせて使用することもできる.策略はモジュール化設計である.

戦略リスク

  1. 逆回線信号は,反響の深度が大きい場合が発生する可能性があります.

  2. 負力指数パラメータの設定は,繰り返しテストして最適化する必要があります.

  3. 多因子総合戦略のパラメータ調整は複雑で,大量の歴史データテストが必要である.

戦略の最適化

  1. join 量化モジュールは,より多くのデータソースを接続し,より長い期間でより豊富なデータを取得します.

  2. 機械学習の方法を適用し,パラメータの組み合わせを自動的に検索し,評価する.

  3. 単一損失を抑えるための損失防止メカニズムの追加

要約する

この戦略は,反転技術の分析と定量指標を総合的に使用し,二重確認によって信号の質を向上させ,モジュール化度が高い,拡張性強,実用型戦略である.その後,より先進的な技術手段を導入することで最適化することができ,より複雑な市場環境に適合する.

ストラテジーソースコード
/*backtest
start: 2023-11-13 00:00:00
end: 2023-11-20 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 29/05/2019
// This is combo strategies for get 
// a cumulative signal. Result signal will return 1 if two strategies 
// is long, -1 if all strategies is short and 0 if signals of strategies is not equal.
//
// 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
//  Bear Power Indicator
//  To get more information please see "Bull And Bear Balance Indicator" 
//  by Vadim Gimelfarb. 
//
// 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

BearPower(SellLevel, BuyLevel) =>
    value =  iff (close < open ,  
              iff (close[1] > open ,  max(close - open, high - low), high - low), 
               iff (close > open, 
                 iff(close[1] > open, max(close[1] - low, high - close), max(open - low, high - close)), 
                  iff(high - close > close - low, 
                   iff (close[1] > open, max(close[1] - open, high - low), high - low), 
                     iff (high - close < close - low, 
                      iff(close > open, max(close - low, high - close),open - low), 
                       iff (close > open, max(close[1] - open, high - close),
                         iff(close[1] < open, max(open - low, high - close), high - low))))))
    pos = 0.0
    pos := iff(value > SellLevel, -1,
	   iff(value <= BuyLevel, 1, nz(pos[1], 0))) 

    pos

strategy(title="Combo Backtest 123 Reversal & Bear Power", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
SellLevel = input(30)
BuyLevel = input(3)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBearPower = BearPower(SellLevel, BuyLevel)
pos = iff(posReversal123 == 1 and posBearPower == 1 , 1,
	   iff(posReversal123 == -1 and posBearPower == -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 ? red: possig == 1 ? green : blue )