逆転と将来の境界線を統合する定量的な取引戦略

作者: リン・ハーンチャオチャン開催日:2023年8月12日 (火) 12:00:35
タグ:

img

概要

この戦略は123の逆転戦略とフューチャーライン・オブ・デマルケーション (FLD) 戦略を統合し,両方の戦略が同時にシグナルを生成するときにポジションに入ったり出たりする定量的な取引戦略を実装する.主にインデックス先物市場に適用され,短期逆転信号と中長期トレンド信号の組み合わせから機会を把握し,中短期保有取引を行う.

原則

123 逆転戦略

123の逆転戦略は"How I Tripled My Money in the Futures Market"という本から由来する.閉店価格が連続2日間逆転パターンを示し,9日間のスローストキャストが50を下回るときはロングになり,閉店価格が連続2日間逆転パターンを示し,9日間の急速ストキャストが50を超えるとショートになります.

境界線戦略の将来の線

フューチャー・ライン・オブ・デマルケーション (FLD) 戦略は,価格変動の周期性に基づいたトレンドフォローする戦略である.FLDラインは,中位値,高値,低値を約半サイクル前に移動することによって描かれる.価格が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 )

もっと