二重指標の定量戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-21 10:59:16
タグ:

img

概要

この戦略は123リバーサルインジケーターとRAVIインジケーターを組み合わせて取引信号を生成する.123リバーサルとはリバーサルタイプの戦略に属し,過去2日の価格動向を使用して将来の価格動向を決定する.RAVIインジケーターは価格がオーバーバイトまたはオーバーセールゾーンに入ったかどうかを決定する.戦略は両方のインジケーターからの組み合わせた信号に基づいて,ロングまたはショートに行くことを決定する.

戦略の論理

123 逆転

この指標はストカスタスティック指標のK値に基づいています.具体的には,今日の閉値が前2日より低く,9日スローストカスタスティックラインが50を下回るとロングになります.今日の閉値が前2日より高く,9日スローストカスタスティックラインが50以上になるとショートになります.

RAVI インディケーター

この指標は,高速移動平均値と遅移動平均値の違いを計算することによって信号を生成する.特に,7日間MAと65日間MAの違い.差が限界値を超えると長くなって,限界値を下回ると短くなってしまいます.したがって,高速移動平均値と遅やかな移動平均値が交差するときに,過剰購入および過剰販売エリアを特定することができます.

戦略信号

123 リバースとRAVIが方向に合意したときに信号が生成される.長信号は2つのインジケーターが1を表示するとトリガーされ,短信号は2つのインジケーターが-1を表示するとトリガーされる.この二重確認は,1つのインジケーターからの誤った信号を回避する.

利点を分析

  • 2つの指標を組み合わせることで,信号の正確性が向上し,誤った信号が避けられます
  • 123 リバースは価格データ,RAVIは移動平均データを使って複数の視点から動向を決定する
  • RAVIのパラメータは調整可能で,異なる製品と市場環境に最適化できます
  • 逆転とトレンドの組み合わせにより,逆転とトレンドの両方を把握できます.

リスク と 最適化

  • 二重指標の組み合わせは,時には矛盾する信号につながる. 価格偏差パラメータは,二つの指標の間の価格偏差が値内にあるとき,信号を誘発するために導入することができます.
  • 123 逆転は高周波戦略です.低周波戦略と組み合わせれば,取引頻度を下げることができます.
  • RAVIは中長期トレンドを把握するのに適しています.短期指標と組み合わせるとリスク管理が向上します.

結論

この戦略は逆転とトレンドの両方の要因を考慮する. 双重確認は誤った信号を避けるのに役立ちます. 次のステップは,適応パラメータ最適化のための機械学習アルゴリズムを導入することかもしれません. または,この戦略を他の戦略タイプと組み合わせて,利益を維持し,最大引き下げを削減しながらポートフォリオの多様化を達成することができます.


/*backtest
start: 2023-11-20 00:00:00
end: 2023-12-20 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 31/05/2021
// 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 indicator represents the relative convergence/divergence of the moving 
// averages of the financial asset, increased a hundred times. It is based on 
// a different principle than the ADX. Chande suggests a 13-week SMA as the 
// basis for the indicator. It represents the quarterly (3 months = 65 working days) 
// sentiments of the market participants concerning prices. The short moving average 
// comprises 10% of the one and is rounded to seven.
//
// 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


RAVI(LengthMAFast, LengthMASlow, TradeLine) =>
    pos = 0.0
    xMAF = sma(close, LengthMAFast)
    xMAS = sma(close, LengthMASlow)
    xRAVI = ((xMAF - xMAS) / xMAS) * 100
    pos:= iff(xRAVI > TradeLine, 1,
    	   iff(xRAVI < TradeLine, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Range Action Verification Index (RAVI)", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Range Action Verification Index (RAVI) ----")
LengthMAFast = input(title="Length MA Fast", defval=7)
LengthMASlow = input(title="Length MA Slow", defval=65)
TradeLine = input(0.14, step=0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posRAVI = RAVI(LengthMAFast, LengthMASlow, TradeLine)
pos = iff(posReversal123 == 1 and posRAVI == 1 , 1,
	   iff(posReversal123 == -1 and posRAVI == -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 )

もっと