バンドパスコンボ戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-01 10:45:12
タグ:

img

概要

これは2つの要因 - 逆転と帯域通過 - によって駆動されるコンボ戦略で,多要素の重複を達成し,異なる市場状況に適応します.

戦略の論理

この戦略は2つのサブ戦略で構成されています.

  1. 123 逆転戦略: 閉じる価格が2日連続で下がり,今日の閉じる価格が前2日の最低価格を突破し,9日ストカスタスティックオシレータの速い線がスローラインを越えると,ロング.閉じる価格が2日連続で上昇し,今日の閉じる価格が前2日の最高価格を下回り,高速線がスローラインを下回ると,ショート.

  2. バンドパスフィルター: 特定の期間でバンドパス指標を計算し, 限界値を超えるとロング, 下になるとショートします.

両方の戦略が長シグナルを出せばロングポジションを取ります 両方とも短シグナルを出せばショートポジションを取ります そうでなければすべてのポジションをクリアします

利点

  • 二重要因によって動いて,様々な市場状況に適応し,制度を超えて収益性がある
  • 123 リバースは,レンジ・バインド市場でのリバースの機会を把握する
  • バンドパスのフィルタ トレンドする市場の動向
  • 組み合わせた信号は,誤った取引を検証し,回避します.

リスク

  • 不適切なパラメータは,過剰取引を引き起こす可能性があります
  • 不安定な市場では多重損失が発生する可能性があります
  • トランザクションコストを監視する必要がある

強化

  • バンドパス計算を最適化するためにバンドパスフィルターパラメータを調整する
  • 123の逆転パラメータを調整して,長/短逆転の識別を最適化します.
  • 単一の取引におけるストップ損失をコントロール損失に追加する

概要

この戦略は,マルチファクター駆動量的な取引を達成するために,逆転とトレンド要因を統合する. 双要素検証は,誤った取引の確率を軽減し,戦略をさまざまな市場でうまく機能させる. パラメータチューニングとストップロスのさらなる改善は,戦略の安定性と収益性を向上させる.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 21/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
// The related article is copyrighted material from
// Stocks & Commodities Mar 2010
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
//
// 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


Bandpass_Filter(Length, Delta, TriggerLevel) =>
    xPrice = hl2
    beta = cos(3.14 * (360 / Length) / 180)
    gamma = 1 / cos(3.14 * (720 * Delta / Length) / 180)
    alpha = gamma - sqrt(gamma * gamma - 1)
    BP = 0.0
    pos = 0.0
    BP := 0.5 * (1 - alpha) * (xPrice - xPrice[2]) + beta * (1 + alpha) * nz(BP[1]) - alpha * nz(BP[2])
    pos := iff(BP > TriggerLevel, 1,
	       iff(BP <= TriggerLevel, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Bandpass Filter", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthBF = input(20, minval=1)
Delta = input(0.5)
TriggerLevel = input(0)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBandpass_Filter = Bandpass_Filter(LengthBF, Delta, TriggerLevel)
pos = iff(posReversal123 == 1 and posBandpass_Filter == 1 , 1,
	   iff(posReversal123 == -1 and posBandpass_Filter == -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 ) 

もっと