参考金字塔系统里的自定义均线函数的格式,自己编了一个序列模式下的一个自定义函数,结果输出为0,请高手给看看问题出在哪里。
Function chan_biduan(Formula,high,low)
'防止公式逐周期模式时调用
If Formula.WorkMode = 0 Then
Exit Function
End If
'high数组数据长度一定会与Formula.DataSize-1相等
DataCount = UBound(high)
If DataCount <> Formula.DataSize-1 Then
Exit Function
End If
'定义计算返回的数组
Dim Highxiu
Redim Highxiu(EndPos)
Dim Lowxiu
Redim Lowxiu(EndPos)
Dim Bi
Redim Bi(EndPos)
xiangbao=0
For Shift = 0 To DataCount
Bi(Shift)=0 '初始化Bi数组
Highxiu=High(Shift)
Lowxiu=Low(Shift)
If Shift>=1 and xiangbao=0 then
if Highxiu(Shift)>Highxiu(Shift-1) and Lowxiu(Shift)>Lowxiu(Shift-1) then xiangbao=1
if Highxiu(Shift)<Highxiu(Shift-1) and Lowxiu(Shift)<Lowxiu(Shift-1) then xiangbao=-1
end if
if xiangbao=1 then
if Highxiu(Shift)>=Highxiu(Shift-1) and Lowxiu(Shift)<Lowxiu(Shift-1) then
Lowxiu(Shift)=Lowxiu(Shift-1)
End if
if Highxiu(Shift)<Highxiu(Shift-1) and Lowxiu(Shift)>=Lowxiu(Shift-1) then
Highxiu(Shift)=Highxiu(Shift-1)
End if
if Highxiu(Shift)<Highxiu(Shift-1) and Lowxiu(Shift)<Lowxiu(Shift-1) then
xiangbao=-1
end if
end if
If xiangbao=-1 then
if Highxiu(Shift)>Highxiu(Shift-1) and Lowxiu(Shift)<=Lowxiu(Shift-1) then
Highxiu(Shift)=Highxiu(Shift-1)
End if
if Highxiu(Shift)<=Highxiu(Shift-1) and Lowxiu(Shift)>Lowxiu(Shift-1) then
Lowxiu(Shift)=Lowxiu(Shift-1)
End if
if Highxiu(Shift)>Highxiu(Shift-1) and Lowxiu(Shift)>Lowxiu(Shift-1) then
xiangbao=1
end if
end if
Next
chan_biduan=Highxiu
End Function
另外试了一下系统举得序列模式下的自定义均线函数,也是输出为0,不知为什么。