以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  高级功能研发区  (http://www.weistock.com/bbs/list.asp?boardid=5)
----  求助咨询专家:如何识别W底或者M顶  (http://www.weistock.com/bbs/dispbbs.asp?boardid=5&id=48739)

--  作者:hnpn
--  发布时间:2013/2/21 11:09:19
--  求助咨询专家:如何识别W底或者M顶
    请问VBS或者C++能否实现识别分时图和K线图的W底或者M顶?如何考虑,请指导一个方法,谢谢
--  作者:RogarZ
--  发布时间:2013/2/21 11:37:19
--  
模式识别我们无法给出答案。用户自己思考解决。
具体实现起来 遇到软件使用功能上的问题 欢迎到论坛解决

--  作者:admin
--  发布时间:2013/2/21 11:44:56
--  

给你个思路,下面的是金字塔自带的判断三角形向上突破的一个VBA的范例

 

Function TriangleShape(Formula,Cyc,SCyc,ECyc)
    \'msgbox cyc & "-" & scyc & "-" & ecyc
 \'该函数计算当前位置图形是否是三角形突破,如果是则返回1,否则返回0。该函数只有在选股时才能使用。
 TriangleShape=0
 
 \'如果是分时数据或者分笔成交那么直接返回
 If Formula.ParentGrid.DataType = 0 or Formula.ParentGrid.CycType = 10 Then
  Exit Function
 End If
 
 \'得到K线数据对象
 Set History = Formula.ParentGrid.GetHistoryData()
 
 If History.Count < Cyc+3 Then
  Exit Function
 End If
 
 \'为了加快处理速度,只有公式在执行最后一个周期时使用。这就意味着只能在选股时使用该函数
 \'如果你在公式测试中使用,请注释掉以下语句
 If Formula.IndexData < History.Count-1 Then Exit Function
 
 \'下面的代码判断当前图形是否可能为三角形态
 \'开始位置SCyc周期内的高低价格为三角形态的开始
 StartPos = Formula.IndexData - (Cyc+2)
 EndPos = Formula.IndexData-3
 High = History.High(StartPos)
 Low  = History.Low(StartPos)
 For I = StartPos To StartPos+SCyc
  If History.High(I) > High Then
   High = History.High(I)
  End If
  If History.Low(i) < Low Then
   Low = History.Low(I)
  End If
 Next
 
 \'ECyc周期内的周期高低价格为三角的结束
 High2 = History.High(EndPos - ECyc)
 Low2  = History.Low(Endpos-ECyc)
 for i = endpos - ECyc to endpos
  If History.High(I) > High2 Then
   High2 = History.High(I)
  End If
  If History.Low(i) < Low2 Then
   Low2 = History.Low(I)
  End If
 next
 
 \'最后图形范围为开始图形的1/2的话,初步表明是可以做为三角形的结束
 if high2-low2 <= 0 then
  exit function
 end if
 
 If (High-Low) / (high2-low2) < 2 Then
  Exit Function
 End if
 
 if high2 > high or low2 < low then
  exit function
 end if
 
 \'如果中间有超过三角形边界的地方,三角图形则不成立
 \'用斜率计算图形边界
 \'计算上边界
 Slope = (high2-high) / (Endpos-StartPos)
 b = high - slope * startpos
 
 for i = startpos+SCyc to endpos
  temp = slope * i + b
  price = (history.open(i)+history.close(i))/2
  if temp < price then
   exit function
  end if
 next
 
 \'计算下边界
 slope = (low2-low) / (endpos - startpos)
 b = low - slope * startpos
 
 for i = startpos to endpos-3
  temp = slope * i + b
  price = (history.open(i)+history.close(i))/2
  if temp > price then
   exit function
  end if
 next 
 
 \'如果3日后的价格突破了三角型结束的上边线认为突破成功
 if history.close(Formula.IndexData) > high2 then
  TriangleShape = 1
 end if
 
 
End Function


--  作者:hnpn
--  发布时间:2013/2/21 12:57:53
--  

太感谢了,很有启发。