欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 自定义函数的问题

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有4203人关注过本帖平板打印复制链接

主题:自定义函数的问题

帅哥哟,离线,有人找我吗?
nk1m
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:13 积分:120 威望:0 精华:0 注册:2011/10/8 12:29:50
自定义函数的问题  发帖心情 Post By:2011/11/19 17:53:32    Post IP:112.85.235.138[只看该作者]

参考金字塔系统里的自定义均线函数的格式,自己编了一个序列模式下的一个自定义函数,结果输出为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,不知为什么。



 回到顶部