因backset函数不能嵌套,所以我自写函数,但我写的自定义函数太慢了,实盘无法用,哪个大侠能不能帮我优化下,咸激不尽
我在公式里这么调用的:
yy:HPPOS();
drawline(yy,h,yy,h,2),linethick3,colorgreen;
以下为自定义函数部分:
Function HpPos(Formula)
Set History = Formula.ParentGrid.GetHistoryData()
DataCount = 0
rTime=0
lTime=0
i=history.Count-4
do
boolH=history.high(i)>history.high(i-1) and history.high(i)>=history.high(i-2) and history.high(i)>=history.high(i-3) _
and history.high(i)>=history.high(i+1) and history.high(i)>=history.high(i+2) and history.high(i)>=history.high(i+3)
boolL=history.Low(i)
and history.Low(i)<=history.Low(i+1) and history.Low(i)<=history.Low(i+2) and history.Low(i)<=history.Low(i+3)
if boolH and (not boolL) then
DataCount=DataCount+1
if DataCount=1 then
RTime=i
end if
if DataCount=2 then
LTime=i
exit do
end if
end if
i=i-1
loop
if Formula.IndexData=rTime then
HpPos=history.high(rTime)
exit function
end if
if Formula.IndexData=lTime then
HpPos=history.high(lTime)
exit function
end if
End Function
补充一下,我用的是多图组合,一个图上可以看好几个品种的
[此贴子已经被作者于2010-6-29 22:04:47编辑过]