双重ゴールドクロス逆転取引戦略

作者: リン・ハーンチャオチャン,日付: 2023年11月3日 15:32:38
タグ:

img

概要

ダブルゴールドクロスリバーサル・トレード戦略は,複数の技術分析指標を組み合わせたトレード戦略である. 複数のトレード信号を統合し,より信頼性の高いトレード信号を得るために,123リバーサル・パターンの戦略と素数帯の指標を組み込む.

戦略の原則

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

  1. 123 逆転パターン戦略

    ショートシグナルは,株の閉盘価格に基づいて取引信号を生成する.シグナルは,連続した日の閉盘価格の関係が変化すると発生する.具体的には,前の閉盘価格が2日前のものよりも高く,現在の閉盘価格が前日よりも低いときにショートシグナルが生成される.前の閉盘価格が2日前のものよりも低く,現在の閉盘価格が前日よりも高くなったときにロングシグナルが生成される.さらに,ストカスティックオシレーターが横断したときのみシグナルが活性化される.つまり,ロングシグナルが活性化されるのは,高速線がスローラインを下回る時のみである.ショートシグナルが活性化されるのは,高速線がスローラインの上回る時のみである.

  2. 素数帯の戦略

    この戦略は,価格変動範囲を決定するために,素数のユニークな分布を使用する.まず,価格の一定の百分比範囲内の最高と最低の素数を位置付け,二つの素数列をバンドとしてプロットする.価格がバンドに触ると取引信号が生成される.特に,価格が上部帯を超えると長い信号が起動する.価格が下部帯を下回るとショート信号が起動する.

この2つのサブ戦略は,最終的な取引シグナルを生成するために組み合わせられます.つまり,ロングシグナルは,2つの戦略がロングシグナルを生成するときにのみ生成されます.ショートシグナルも同じです. 2つの戦略からのシグナルが相互に矛盾した場合,取引は実行されません.

利点分析

この戦略には以下の利点があります.

  1. シグナル統合による収益性の向上

    2つの異なるタイプの戦略からのシグナルを組み合わせることで,シグナルの信頼性が確認され,高確率で収益性の高い取引機会を特定することができます.

  2. 123の逆転パターンの高い勝利率

    123の逆転パターンは,短期間の買い過ぎや売り過ぎの状況から生じる逆転機会を把握できる古典的な逆転戦略であり,それによってライブ取引では比較的高い勝率を持っています.

  3. 素数帯は価格パターンを捉える

    素数帯は,価格変動範囲を決定するために素数のユニークなランダム性を利用し,主観的な偏見を避け,取引信号の客観性を高めます.

  4. 新しい戦略の論理は搾取を避ける

    複数の指標の革新的な統合により 戦略はリバースエンジニアリングや模倣戦略による利用に 弱いものになります

リスク分析

この戦略には次のリスクも伴う.

  1. 失敗した逆転リスク

    逆転戦略として 123 パターンの逆転が失敗すると損失を起こす可能性があります

  2. 素数帯の不具合

    素数帯は,適切なパラメータ調整に依存する.間違ったパラメータは,それを非効果的にする可能性があります.

  3. 複数の信号による取引頻度増加

    2つの信号源を組み合わせると,より多くの取引が生成される.過剰な取引コストが適切に制御されない場合,利益を損なう可能性があります.

  4. 難解な最適化

    2つの統合戦略からパラメータを最適化することは 難しいことがあります

最適化 の 提案

戦略は以下の側面で最適化できます.

  1. ストップ・ロスは,トレード・ロスの制限に含まれます.

  2. 最新の市場状況に合わせて 素数帯のパラメータを最適化する

  3. 取引頻度を制御して,取引コストが過剰に上昇しないようにする.

  4. 戦略パラメータの最適化を自動化するための機械学習アルゴリズムを導入する

  5. 信号の精度をさらに向上させるために 音量指標のような 確認指標を追加します

概要

ダブルゴールドクロスリバーサル・トレード戦略は,ノイズ・トレードをフィルターし,シグナル検証を通じて高確率の取引機会を特定するために複数の技術指標を統合している.しかし,戦略を強化するために適切な最適化によって緩和する必要がある固有リスクも伴う.リスクが制御されていると,戦略は比較的安定し信頼性の高い定量的なトレード戦略になることができます.


/*backtest
start: 2023-10-01 00:00:00
end: 2023-10-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 23/04/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
// Determining market trends has become a science even though a high number 
// or people still believe it’s a gambling game. Mathematicians, technicians, 
// brokers and investors have worked together in developing quite several 
// indicators to help them better understand and forecast market movements.
// The Prime Number Bands indicator was developed by Modulus Financial Engineering 
// Inc. This indicator is charted by indentifying the highest and lowest prime number 
// in the neighborhood and plotting the two series as a band.
//
// 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

PrimeNumberUpBand(price, percent) =>
    res = 0.0
    res1 = 0.0
    for j = price to price + (price * percent / 100)
        res1 := j
	    for i = 2 to sqrt(price)
        	res1 := iff(j % i == 0 , 0, j)
            if res1 == 0 
                break
		if res1 > 0 
		    break
    res := iff(res1 == 0, res[1], res1)
    res

PrimeNumberDnBand(price, percent) =>
    res = 0.0
    res2 = 0.0
    for j = price to price - (price * percent / 100)
        res2 := j
	    for i = 2 to sqrt(price)
        	res2 := iff(j % i == 0 , 0, j)
            if res2 == 0 
                break
		if res2 > 0 
		    break
    res := iff(res2 == 0, res[1], res2)
    res

PNB(percent, Length,srcUp,srcDn) =>
    pos = 0.0
    xPNUB = PrimeNumberUpBand(srcUp, percent)
    xPNDB = PrimeNumberDnBand(srcDn, percent)
    xHighestPNUB = highest(xPNUB, Length)
    xLowestPNUB = lowest(xPNDB, Length)
    pos:= iff(close > xHighestPNUB[1], 1,
             iff(close < xLowestPNUB[1], -1, nz(pos[1], 0))) 
    pos


strategy(title="Combo Backtest 123 Reversal & Prime Number Bands", 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, "---- Prime Number Bands ----")
percent = input(5, minval=0.01, step = 0.01, title="Tolerance Percentage")
Length_PNB = input(5, minval=1)
srcUp = input(title="Source Up Band", type=input.source, defval=high)
srcDn = input(title="Source Down Band", type=input.source, defval=low)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPNB = PNB(percent, Length_PNB,srcUp,srcDn)
pos = iff(posReversal123 == 1 and posPNB == 1 , 1,
	   iff(posReversal123 == -1 and posPNB == -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 )

もっと