Zスコア価格ブレイク戦略

作者: リン・ハーンチャオチャン, 日時: 2023-12-07 15:17:43
タグ:

img

概要

Zスコア価格ブレイクアウト戦略は,現在の価格が異常状態にあるかどうかを判断するために,価格のzスコア指標を使用し,取引信号を生成する.価格のzスコアが値を下回りまたは上回りすると,価格は異常状態に入ったことを意味し,この時点でロングまたはショートポジションを取ることができる.

戦略原則

この戦略の主な指標は,次のように計算される価格のzスコアです.

Z_score = (C - SMA(n)) / StdDev(C,n)

Cは閉じる価格,SMA (n) は n 期間の単純な移動平均値,StdDev (C,n) は n 期間の閉じる価格の標準偏差である.

Zスコアは,現在の価格が平均価格から偏差する程度を反映する.価格 zスコアが一定の正値 (例えば+2) よりも大きいとき,現在の価格が平均価格より2標準偏差,比較的高いレベルを超えていることを意味します.特定の負値 (例えば-2) よりも小さいとき,現在の価格が平均価格より2標準偏差,比較的低いレベルを下回っていることを意味します.

この戦略は,まず価格のzスコアを計算し,その後,正値と負値 (例えば0と0) を設定する. zスコアが正値を超えると,購入信号を生成する.負値を下ると,販売信号を生成する.

利点分析

  • 価格異常を判断するために価格zスコアを使用することは,一般的な効果のある定量的な方法です.
  • 簡単に長期と短期の両方取引を達成
  • フレキシブルなパラメータ設定,調整可能なサイクル,限界値など
  • 他の指標と組み合わせて取引システムを作ることができる.

リスク分析

  • Zスコア戦略は粗末で 誤った信号に易い
  • サイクルのような適切なパラメータを設定する必要があります.
  • リスク制御のためのストップ・ロスの戦略を検討する必要がある

オプティマイゼーションの方向性

  • 最適なサイクルを見つけるためにサイクルパラメータを最適化
  • 誤った信号を減らすために,正値と負値を最適化する
  • フィルター条件を追加し,他の指標と組み合わせる
  • ストップ損失戦略を追加

概要

Zスコア価格ブレイクアウト戦略は,現在の価格が異常状態にあるかどうかを判断し,価格 zスコアの正と負に応じて取引する.この戦略はシンプルで実行が容易で,双方向取引を可能にしますが,いくつかのリスクもあります.パラメータを最適化し,ストップロスを追加し,他の指標と組み合わせることで,この戦略は完全な定量的な取引システムを形成するために強化することができます.


/*backtest
start: 2023-11-29 00:00:00
end: 2023-12-04 19:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 18/01/2017
// The author of this indicator is Veronique Valcu. The z-score (z) for a data 
// item x measures the distance (in standard deviations StdDev) and direction 
// of the item from its mean (U):
//     z = (x-StdDev) / U
// A value of zero indicates that the data item x is equal to the mean U, while 
// positive or negative values show that the data item is above (x>U) or below 
// (x Values of +2 and -2 show that the data item is two standard deviations 
// above or below the chosen mean, respectively, and over 95.5% of all data 
// items are contained within these two horizontal references (see Figure 1).
// We substitute x with the closing price C, the mean U with simple moving 
// average (SMA) of n periods (n), and StdDev with the standard deviation of 
// closing prices for n periods, the above formula becomes:
//     Z_score = (C - SMA(n)) / StdDev(C,n)
// The z-score indicator is not new, but its use can be seen as a supplement to 
// Bollinger bands. It offers a simple way to assess the position of the price 
// vis-a-vis its resistance and support levels expressed by the Bollinger Bands. 
// In addition, crossings of z-score averages may signal the start or the end of 
// a tradable trend. Traders may take a step further and look for stronger signals 
// by identifying common crossing points of z-score, its average, and average of average. 
//
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
////////////////////////////////////////////////////////////
strategy(title="Z-Score Strategy", shorttitle="Z-Score Strategy")
Period = input(20, minval=1)
Trigger = input(0)
reverse = input(false, title="Trade reverse")
hline(Trigger, color=purple, linestyle=line)
xStdDev = stdev(close, Period)
xMA = sma(close, Period)
nRes = (close - xMA) / xStdDev
pos = iff(nRes > Trigger, 1,
	   iff(nRes < Trigger, -1, nz(pos[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)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(nRes, color=blue, title="Z-Score")

もっと