反転と将来の移動平均を組み合わせた定量的な取引戦略


作成日: 2023-12-08 12:00:35 最終変更日: 2023-12-08 12:00:35
コピー: 0 クリック数: 624
1
フォロー
1621
フォロワー

反転と将来の移動平均を組み合わせた定量的な取引戦略

概要

この戦略は123逆転戦略と未来進出均線戦略を融合し,両方の戦略が同時に信号を発したときにエントラまたはエグザラを行う定量化取引戦略を実現する.この戦略は主に株式指数期貨市場に適用され,短期逆転信号と中期長期のトレンド信号の組み合わせを捕捉し,中期期間のポジション取引を実現する.

戦略原則

123 逆転戦略

123の逆転策は,先物市場での資金の3倍増の方法について書かれた本に由来する.この戦略は,閉店価格が2日連続で逆転し,K線が50を下回った9日連続で多額の取引を行うとき,閉店価格が2日連続で逆転し,K線が50を下回った9日連続で空売りを行うときである.

平均線戦略の未来

フューチャー・ラインズ・オブ・デマルケーション (FLD) は,価格変動の周期的法則に基づくトレンド追跡戦略である.FLD線は,価格の中値,高値,または低値を未来に平行して約半サイクル描画し,価格線がFLD線を横切るときに取引信号を生成する.

優位分析

この戦略は,逆転戦略とトレンド追跡戦略を組み合わせて,短期市場逆転の機会と中長期のトレンド方向を同時に捕捉し,複数の時間尺度の定量取引を実現します.逆転戦略は,短期間の利益の機会を提供し,トレンド追跡部分は,全体の取引方向がトレンドと一致することを保証し,取引リスクを効果的に制御します.さらに,将来の推移均線の自律的適応特性は,戦略の安定性を高めます.

リスク分析

この戦略は,主に反転信号の偽突破のリスクとFLD線判断の誤りが発生するリスクに直面している. 前者については,パラメータを調整して反転信号を確認するか,または他の補助的な判断指標を追加して判断の正確性を向上させることができる. 後者については,パラメータを最適化して,市場の波段法則をより正確に記述できるようにする必要がある. さらに,大周期的な傾向が反転するときにFLD線が誤りが出る可能性にも警戒する必要がある.

最適化の方向

  1. 逆転戦略の改善,その他の指標のフィルタリング 確認信号,偽突破の確率の低下
  2. 周期法則をより正確に記述できるかどうか,異なるFLD線参数と比較
  3. ストップロズロジックが追加され,単一損失のリスクを制御します.
  4. 異なる品種のパラメータの効果をテストする

要約する

この戦略は,逆転とトレンドの取引理念を組み合わせて,中短期の時間枠で安定した利益を達成します.将来的には,信号の正確性,トレンドの正確性,リスクの制御などの観点から最適化することができ,戦略のパラメータの範囲がより広く,安定性がより強くなります.

ストラテジーソースコード
/*backtest
start: 2022-12-01 00:00:00
end: 2023-12-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 28/08/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
//  An FLD is a line that is plotted on the same scale as the price and is in fact the 
//  price itself displaced to the right (into the future) by (approximately) half the 
//  wavelength of the cycle for which the FLD is plotted. There are three FLD's that can be 
//  plotted for each cycle:
//    An FLD based on the median price.
//    An FLD based on the high price.
//    An FLD based on the low price.
//
// 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


FLD(Period,src) =>
    pos = 0
    pos := iff(src[Period] < close , 1,
             iff(src[Period] > close, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & FLD's - Future Lines of Demarcation", shorttitle="Combo", overlay = true)
Length = input(15, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
Period = input(title="Period", defval=40)
src = input(title="Source", type=input.source, defval=close)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posFLD = FLD(Period,src)
pos = iff(posReversal123 == 1 and posFLD == 1 , 1,
	   iff(posReversal123 == -1 and posFLD == -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 )