QQE(計算式、チャート、エクセルVBAコード)テクニカル指標


2009年2月26日



 

QQEについて、計算式、チャート、エクセルVBAコードなど

 

QQEは正式名称をQualitative Quantitative Estimationという指標ですが、相対力指数(RSI)を用いて計算されます。

あまりメジャーな指標ではありませんが、2本の線を併用することで、大きなトレンドとその時々の相場の上下への強さを見る事ができます。

 

 

 

QQEの計算式(N=RSIパラメータ、S=指数移動平均パラメータ)

1)N本のRSIのS本の指数平滑移動平均線を求め、RSI_EMAとします。

2)直前の指数平滑移動平均と現在の指数平滑移動平均の差の絶対値を求めEMA_ABSとする。

3)EMA_ABSの2N+1(Nは上記RSIのパラメータ)本の指数平滑移動平均線を求め、係数をかけQQE_facとする。

4)QQE_1の初期値を0として(QQE_1=直前QQE)、下記A~Dの条件分岐にてQQEを求める

 

A RSI_EMA<QQE_1 ならばCへ

B RSI_EMA>QQE_1 ならばDへ

C 直前のRSI_EMA < QQE_1 且つ RSI_EMA + QQE_fac > QQE_1 ならば
QQE = QQE_1 でなければ QQE = RSI_EMA + QQE_fac

D 直前のRSI_EMA > QQE_1 且つ RSI_EMA – QQE_fac < QQE_1 ならば
QQE = QQE_1 でなければ QQE = RSI_EMA – QQE_fac

5)求められたQQEとRSI_MAがQQEのラインとして描画されます。

 

上記計算式で使用する係数ですが、ひとつのQQEを求めるのに、4.236や2.628といった組み合わせで2種類使用するようです。

 

 

QQEのチャート

※RSI:9(水色) EMA:10 係数: 4.236(赤色)、2.628(黄色)

 

 

※RSI:18(水色) EMA:21 係数: 4.236(赤色)、2.628(黄色)

 

 

 

QQEのエクセルVBAコード

‘※ エクセルの1列目(A列)に行番号、2列目(B列)に日時、
‘※ 3列目(C列)~6列目(F列)に始値・高値・安値・終値
‘********************************
‘ num_n :RSI採用本数
‘ num_e :指数平滑移動平均線採用本数
‘ num:現在の行
‘ r_now:現在値
‘ cell_1~11:計算値書き込み列
‘ fac1:係数1
‘ fac2:係数2
‘ ※cell_4にRSI値、cell_10にQQE(係数1)、
‘ ※cell_11にQQE(係数2)を入力
‘********************************
If num >= 2 + num_n Then

‘////RSIの計算
If Cells(num – 1, 6) <> “” Then
Cells(num, cell_1) = Cells(num, 6) – Cells(num – 1, 6)
End If
If Cells(num – (num_n – 1), cell_1) <> “” Then
If Cells(num – 1, cell_4) = “” Then
rsi1_max = Application.SumIf(Range(Cells(num – (num_n – 1), cell_1), _
Cells(num, cell_1)), “>0”) / num_n
rsi1_min = Abs(Application.SumIf(Range(Cells(num – (num_n – 1), cell_1), _
Cells(num, cell_1)), “<0”)) / num_n
Cells(num, cell_2) = rsi1_max
Cells(num, cell_3) = rsi1_min
Cells(num, cell_4) = rsi1_max / (rsi1_max + rsi1_min) * 100
End If
If Cells(num – 1, cell_4) <> “” Then
If Cells(num, cell_1) > 0 Then
rsi1_max = (Cells(num – 1, cell_2) * (num_n – 1) + Cells(num, cell_1)) _
/ num_n
Else
rsi1_max = Cells(num – 1, cell_2) * (num_n – 1) / num_n
End If
If Cells(num, cell_1) < 0 Then
rsi1_min = (Cells(num – 1, cell_3) * (num_n – 1) – Cells(num, cell_1)) _
/ num_n
Else
rsi1_min = Cells(num – 1, cell_3) * (num_n – 1) / num_n
End If
Cells(num, cell_2) = rsi1_max
Cells(num, cell_3) = rsi1_min
Cells(num, cell_4) = rsi1_max / (rsi1_max + rsi1_min) * 100
End If
‘////RSI_EMAの計算
If num >= 2 + num_n + ema_1 – 1 Then
If Cells(num – 1, cell_5) = “” Then
Cells(num, cell_5) = Application.Average(Range(Cells(num – (ema_1 – 1), _
cell_4), Cells(num, cell_4)))
Else
Cells(num, cell_5) = Cells(num – 1, cell_5) + (2 / (ema_1 + 1)) * _
(Cells(num, cell_4) – Cells(num – 1, cell_5))
Cells(num, cell_6) = Abs(Cells(num – 1, cell_5) – Cells(num, cell_5))
End If
End If
‘////係数の計算
If num >= 2 + num_n + ema_1 + num_n * 2 + 1 – 1 Then
If Cells(num – 1, cell_7) = “” Then
Cells(num, cell_7) = Application.Average(Range(Cells(num – _
((num_n * 2 + 1) – 1), cell_6), Cells(num, cell_6)))
Cells(num, cell_8) = Cells(num, cell_7) * fac1
Cells(num, cell_9) = Cells(num, cell_7) * fac2
Else
Cells(num, cell_7) = Cells(num – 1, cell_7) + (2 / _
((num_n * 2 + 1) + 1)) * (Cells(num, cell_6) – Cells(num – 1, cell_7))
Cells(num, cell_8) = Cells(num, cell_7) * fac1
Cells(num, cell_9) = Cells(num, cell_7) * fac2
End If
End If
‘////QQEの条件分岐計算
If Cells(num, cell_8) <> “” Then
If Cells(num – 1, cell_8) = “” Then tr_1 = 0 Else tr_1 = _
Cells(num – 1, cell_10)
If tr_1 > Cells(num, cell_5) Then
If Cells(num – 1, 12) < tr_1 And Cells(num, cell_5) + _
Cells(num, cell_8) > tr_1 Then
Cells(num, cell_10) = tr_1
Else
Cells(num, cell_10) = Cells(num, cell_5) + Cells(num, cell_8)
End If
End If
If tr_1 < Cells(num, cell_5) Then
If Cells(num – 1, cell_5) > tr_1 And Cells(num, cell_5) – _
Cells(num, cell_8) < tr_1 Then
Cells(num, cell_10) = tr_1
Else
Cells(num, cell_10) = Cells(num, cell_5) – Cells(num, cell_8)
End If
End If
End If
If Cells(num, cell_9) <> “” Then
If Cells(num – 1, cell_9) = “” Then tr_1 = 0 Else tr_1 = _
Cells(num – 1, cell_11)
If tr_1 > Cells(num, cell_5) Then
If Cells(num – 1, cell_5) < tr_1 And Cells(num, cell_5) + _
Cells(num, cell_9) > tr_1 Then
Cells(num, cell_11) = tr_1
Else
Cells(num, cell_11) = Cells(num, cell_5) + Cells(num, cell_9)
End If
End If
If tr_1 < Cells(num, cell_5) Then
If Cells(num – 1, cell_5) > tr_1 And Cells(num, cell_5) – _
Cells(num, cell_9) < tr_1 Then
Cells(num, cell_11) = tr_1
Else
Cells(num, cell_11) = Cells(num, cell_5) – Cells(num, cell_9)
End If
End If
End If
End If
End If

 

 

 

テクニカル指標一覧

罫線談義一覧

(外部リンク)テクニカル指標(Wikipedia)