フィボナッチ係数(フィボナッチ・リトレースメント)(計算式、チャート、エクセルVBAコード)テクニカル指標


2008年12月25日



 

フィボナッチ係数(フィボナッチ・リトレースメント)計算式、エクセルVBAコード

 

フィボナッチ係数は、相場の転換点を探るための指標で、過去一定期間の高値と安値の値幅を1とした場合の、一定率でプロットしたラインを目先の転換点とします。

 

定率は、0.236、0.382、0.5、0.618、0.784が使用されることが多いようです。

 

その計算式、計算方法、エクセルVBAコードを掲載しています。

 

 

 

 

 

フィボナッチ係数の計算式(Nは足数)

まず一定期間の最高値、最安値を計算します。

 

MAX1=過去N本の最高値

MIN1=過去N本の最安値

FR(0.236) = (MAX1-MIN1)× 0.236 + MIN1

FR(0.382) = (MAX1-MIN1)× 0.382+ MIN1

FR(0.5) = (MAX1-MIN1)× 0.5 + MIN1

FR(0.618) = (MAX1-MIN1)× 0.618 + MIN1

FR(0.784) = (MAX1-MIN1)× 0.784 + MIN1

 

 

 

フィボナッチ係数のエクセルVBAコード

‘※ エクセルの1列目(A列)に行番号、2列目(B列)に日時、
‘※ 3列目(C列)~6列目(F列)に始値・高値・安値・終値
‘********************************
‘ fib :最大値・最小値算出採用本数
‘ num:現在の行
‘ cell_max:最大値(fib)書込み列
‘ cell_min:最小値(fib)書込み列
‘ cell_ud:上下方向書込み列
‘ cell_1236:Fib(1.236)書込み列
‘ cell_0764:Fib(0.764)書込み列
‘ cell_0618:Fib(0.618)書込み列
‘ cell_0500:Fib(0.500)書込み列
‘ cell_0382:Fib(0.382)書込み列
‘ cell_0236:Fib(0.236)書込み列
‘ cell_m236:Fib(-0.236)書込み列
‘********************************

tt = 0

If num > 2 + fib + 5 Then
If Application.Max(Range(Cells(num – (fib – 1), 4), Cells(num, 4))) = Cells(num, 4) Then
Cells(num, cell_max) = Cells(num, 4)
Cells(num, cell_ud) = 1
tt = 1
Else
Cells(num, cell_max) = Cells(num – 1, cell_max)
If tt = 0 Then Cells(num, cell_ud) = Cells(num – 1, cell_ud)
End If
If Application.Min(Range(Cells(num – (fib – 1), 5), Cells(num, 5))) = Cells(num, 5) Then
Cells(num, cell_min) = Cells(num, 5)
Cells(num, cell_ud) = -1
tt = 1
Else
Cells(num, cell_min) = Cells(num – 1, cell_min)
If tt = 0 Then Cells(num, cell_ud) = Cells(num – 1, cell_ud)
End If
End If

ma_x = Cells(num, cell_max)
mi_n = Cells(num, cell_min)
sa = ma_x – mi_n
If Cells(num, cell_ud) = 1 _
And Cells(num, cell_max) <> “” And Cells(num, cell_min) <> “” Then
Cells(num, cell_1236) = mi_n + sa * 1.236
Cells(num, cell_0764) = mi_n + sa * 0.764
Cells(num, cell_0618) = mi_n + sa * 0.618
Cells(num, cell_0500) = mi_n + sa * 0.5
Cells(num, cell_0382) = mi_n + sa * 0.382
Cells(num, cell_0236) = mi_n + sa * 0.236
Cells(num, cell_m236) = mi_n + sa * -0.236
End If
If Cells(num, cell_ud) = -1 _
And Cells(num, cell_max) <> “” And Cells(num, cell_min) <> “” Then
ma_x = Cells(num, cell_max)
mi_n = Cells(num, cell_min)
Cells(num, cell_m236) = ma_x – sa * 1.236
Cells(num, cell_0236) = ma_x – sa * 0.764
Cells(num, cell_0382) = ma_x – sa * 0.618
Cells(num, cell_0500) = ma_x – sa * 0.5
Cells(num, cell_0618) = ma_x – sa * 0.382
Cells(num, cell_0764) = ma_x – sa * 0.236
Cells(num, cell_1236) = ma_x – sa * -0.236
End If

 

 

テクニカル指標一覧

罫線談義一覧

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