以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  四周规则能写成VBA模板吗,方便大家学习  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=9089)

--  作者:solarhe2006
--  发布时间:2011/11/22 15:27:34
--  四周规则能写成VBA模板吗,方便大家学习

四周规则能写成VBA模板吗,方便大家学习

HHN:=ref(HHV(HIGH,20),1);
HLN:=ref(LLV(LOW,20),1);

IF H>=HHN then
begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,thisclose);
end

IF L<=HLN then
begin
sell(holding>0,0,thisclose);
buyshort(holding=0,1,thisclose);
end


--  作者:26327756l
--  发布时间:2011/11/22 15:31:50
--  

有必要吗

图表可以实现 VBA还要写一遍。


--  作者:guotx2010
--  发布时间:2011/11/22 21:52:05
--  

任何策略都可以用VBA来实现,只是代码量比后台或图表策略大的多,调试也需要较长的时间。

如果只是单纯的实现开平仓的目的,没有必要使用VBa来做的。

 


--  作者:z7c9
--  发布时间:2011/11/23 11:19:28
--  
Sub ForWeekRule
 dim code
 dim market
 dim cyctype
 dim highest
 dim lowest
 
 code="RU00"
 market="SQ"
 cyctype=5
 
 set historydata =marketdata.GetHistoryData(code,market,cyctype)
 for i=historydata.count-22 to historydata-2
  if historydata.high(i)>highest then
   highest=historydata.high(i)
  end if
  
  if historydata.low(i)<lowest then
   lowest=historydata.low(i)
  end if
 next
 
 if historydata(historydata.count-1)>highest then
  order.buyshort 1,1,0,0,code,market,0,0
  order.buy 1,1,0,0,code,market,0,0
 end if
 
 if historydata(historydata.count-2)<lowest then
  order.SellShort 1,1,0,0,code,market,0,0
  order.sell 1,1,0,0,code,market,0,0
 end if
end sub

--  作者:solarhe2006
--  发布时间:2011/11/23 11:29:04
--  [公告]上海中期北京营业部与金字塔合作

Sub ForWeekRule
 dim code
 dim market
 dim cyctype
 dim highest
 dim lowest
 
 code="RU00"
 market="SQ"
 cyctype=5
 
 set historydata =marketdata.GetHistoryData(code,market,cyctype)
 for i=historydata.count-22 to historydata-2
  if historydata.high(i)>highest then
   highest=historydata.high(i)
  end if
  
  if historydata.low(i)<lowest then
   lowest=historydata.low(i)
  end if
 next
 
 if historydata(historydata.count-1)>highest then
  order.buyshort 1,1,0,0,code,market,0,0
  order.buy 1,1,0,0,code,market,0,0
 end if
 
 if historydata(historydata.count-2)<lowest then
  order.SellShort 1,1,0,0,code,market,0,0
  order.sell 1,1,0,0,code,market,0,0
 end if
end sub