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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → [原创]vbs高频

   

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


  共有10209人关注过本帖树形打印复制链接

主题:[原创]vbs高频

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


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
[原创]vbs高频  发帖心情 Post By:2012/11/23 22:09:35 [只看该作者]

sub marketdata_reportnotify(reportdata)
 dim multiplier
 dim mintick
 dim shortpercent
 dim longpercent
 
 dim buyhoding
 dim buytodayhoding
 dim sellhoding
 dim selltodayhoding
 dim buycost
 dim sellcost
 dim pnl
 dim usemargin
 
 dim orderid
 dim consign
 dim filled
 dim remaining
 dim ordertype
 dim lmtprice
 
 lots=1
 account="888888" 
 
 code=reportdata.label
 market=reportdata.marketname
 
 len=strlen(code)
 prefix=strleft(code,len-2) 
 
 if prefix="IF" then
  totalbars=270 
  myentrytime=time>#9:16:00# and time<#15:14:00#
  myexittime=time>=#15:15:00#
 else
  totalbars=225
  myentrytime=time>#9:01:00# and time<#14:59:00#
  myexittime=time>=#15:00:00#
 end if  

 exitbars=code&"_exitbars"
 actiontime=code&"_actiontime"
 
 set myreport=marketdata.getreportdata(code,market)
 set myhistory=marketdata.gethistorydata(code,market,0) 
 set myminutedata=marketdata.getminutedata(code,market)
 
 barpos1=myhistory.count-1 

 high1=myhistory.high(barpos1-1)
 low1=myhistory.low(barpos1-1)  
 
 barpos2=myminutedata.count-1 
 
 minvolume=200
 
 entrylongcond=myreport.newprice>=high1 and myreport.sellvolume1<=minvolume and barpos1>document.getextdata(exitbars)
 entryshortcond=myreport.newprice<=low1 and myreport.buyvolume1<=minvolume and barpos1>document.getextdata(exitbars)
  
 entrylongprice=myreport.newprice
 entryshortprice=myreport.newprice
 
 call order.contract(code,market,multiplier,mintick,shortpercent,longpercent)
 call order.holdinginfobycode2(code,market,buyholding,buycost,buytodayholding,sellholding,sellcost,selltodayholding,pnl,usemargin,account) 
 
 stoploss=2*mintick 
 breakeven=mintick
 
 sleeptime=1
 
 if document.getextstring(actiontime)="" then
  actiondiff=sleeptime
 else
  actiondiff=datediff("s",document.getextstring(actiontime),now)   
 end if 
 
 if actiondiff<sleeptime then
  exit sub
 end if 
 
 if buyholding=0 and sellholding=0 then
  call getpendingorder(orderid,consign,filled,remaining,0,ordertype,lmtprice,account,0,code,market)
  
  if entrylongcond then        
   if remaining=0 then
    order.buy 0,lots,entrylongprice,0,code,market,account,0     
    call document.setextstring(actiontime,now)
    call document.setextdata(downs,0)
    application.msgout code&"多开下单"        
    exit sub
   elseif entrylongprice>lmtprice then
    order.cancelorder orderid
    call document.setextstring(actiontime,now)
    application.msgout code&"多开撤单" 
    exit sub
   end if     
  end if  
 end if
 
 if buyholding=0 and sellholding=0 then 
  call getpendingorder(orderid,consign,filled,remaining,1,ordertype,lmtprice,account,0,code,market)
  
  if entryshortcond then   
   if remaining=0 then
    order.buyshort 0,lots,entryshortprice,0,code,market,account,0
    call document.setextstring(actiontime,now)
    call document.setextdata(ups,0) 
    application.msgout code&"空开下单"
    exit sub      
   elseif entryshortprice<lmtprice then
    order.cancelorder orderid
    call document.setextstring(actiontime,now)
    application.msgout code&"空开撤单" 
    exit sub
   end if
  end if
 end if 
  
 if buyholding>0 and sellholding=0 then 
  if myminutedata.bidprice(barpos2)<myminutedata.bidprice(barpos2-1) and myminutedata.askprice(barpos2)<myminutedata.askprice(barpos2-1) then
   call document.setextdata(downs,document.getextdata(downs)+1)
  end if
   
  call getpendingorder(orderid,consign,filled,remaining,1,ordertype,lmtprice,account,2,code,market)
  
  if myreport.buyprice1<=buycost-stoploss and myreport.buyvolume1<=minvolume then
   if remaining=0 then
    order.sell 0,buyholding,myreport.buyprice1,0,code,market,account,0  
    call document.setextstring(actiontime,now)
    call document.setextdata(exitbars,barpos1)
    application.msgout code&"多损下单"  
    exit sub 
   elseif myreport.buyprice1<lmtprice then
    order.cancelorder orderid
    call document.setextstring(actiontime,now)
    application.msgout code&"多损撤单"  
    exit sub 
   end if
  elseif document.getextdata(downs)>=1 then
   if remaining=0 then
    order.sell 0,buyholding,buycost+breakeven,0,code,market,account,0  
    call document.setextstring(actiontime,now)
    call document.setextdata(exitbars,barpos1)
    application.msgout code&"多盈下单"   
    exit sub
   elseif buycost+breakeven<lmtprice then
    order.cancelorder orderid
    call document.setextstring(actiontime,now)
    application.msgout code&"多盈撤单"  
    exit sub      
   end if     
  end if 
 end if  
  
 if buyholding=0 and sellholding>0 then
  if myminutedata.bidprice(barpos2)>myminutedata.bidprice(barpos2-1) and myminutedata.askprice(barpos2)>myminutedata.askprice(barpos2-1) then
   call document.setextdata(ups,document.getextdata(ups)+1)
  end if
    
  call getpendingorder(orderid,consign,filled,remaining,0,ordertype,lmtprice,account,2,code,market)

  if myreport.sellprice1>=sellcost+stoploss and myreport.sellvolume1<=minvolume then
   if remaining=0 then
    order.sellshort 0,sellholding,myreport.sellprice1,0,code,market,account,0 
    call document.setextstring(actiontime,now)
    call document.setextdata(exitbars,barpos1)
    application.msgout code&"空损下单"  
    exit sub 
   elseif myreport.sellprice1>lmtprice then
    order.cancelorder orderid
    call document.setextstring(actiontime,now)
    application.msgout code&"空损撤单"  
    exit sub   
   end if
  elseif document.getextdata(ups)>=1 then
   if remaining=0 then
    order.sellshort 0,sellholding,sellcost-breakeven,0,code,market,account,0 
    call document.setextstring(actiontime,now)
    call document.setextdata(exitbars,barpos1)
    application.msgout code&"空盈下单" 
    exit sub
   elseif sellcost-breakeven>lmtprice then
    order.cancelorder orderid
    call document.setextstring(actiontime,now)
    application.msgout code&"空盈撤单"  
    exit sub         
   end if   
  end if
 end if  
end sub

sub getpendingorder()
 application.MsgOut "sss"
 dim orderid
 dim consign
 dim filled
 dim remaining
 dim action
 dim ordertype
 dim lmtprice
 dim account
 dim kaiping
 dim code
 dim market
 
 for i=0 to order.ordernum2-1
  call order.orderinfo2(i,orderid,consign,filled,remaining,action,ordertype,lmtprice,account,kaiping,code,market) 
  
  application.MsgOut "account="&account
  
  if code=mycode and market=mymarket and action=myaction and kaiping=mykaiping and account=myaccount then
   myorderid=orderid
   myconsign=consign
   myfilled=filled
   myremaining=remaining
   myordertype=ordertype
   mylmtprice=lmtprice 
   exit for  
  else
   myorderid=0
   myconsign=0
   myfilled=0
   myremaining=0
   myordertype=0
   mylmtprice=0   
  end if
 next
end sub

sub mytest()
 if time>=#8:23:00# and time<=#8:24:00# then
  application.MsgOut time
 else
  application.MsgOut "aa"
 end if  
end sub


 回到顶部
帅哥哟,离线,有人找我吗?
系统使用者
  2楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:808 积分:667 威望:0 精华:0 注册:2011/4/9 16:17:57
  发帖心情 Post By:2012/11/24 10:43:48 [只看该作者]

无法编译

 回到顶部
帅哥哟,离线,有人找我吗?
lufuding
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:332 积分:1295 威望:0 精华:0 注册:2011/4/19 2:02:59
  发帖心情 Post By:2012/11/24 13:57:41 [只看该作者]

哪位高人翻译(注解)一下

 

请问此策略是基于什么样的理论?


 回到顶部
帅哥哟,离线,有人找我吗?
zwx
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:4 积分:5 威望:0 精华:0 注册:2012/12/1 19:28:24
  发帖心情 Post By:2012/12/1 21:56:07 [只看该作者]

没有注释,谁看得懂呀

 回到顶部
帅哥哟,离线,有人找我吗?
lufuding
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:332 积分:1295 威望:0 精华:0 注册:2011/4/19 2:02:59
  发帖心情 Post By:2013/1/4 18:39:23 [只看该作者]

楼主请翻译(注解)一下,谢谢


 回到顶部