我的一个方法,你参考一下,我曾经用来保存日线,当然期它周期也是可行的。 http://www.oceantribe.org/vb/showthread.php?t=23918 下面"fff"是用VBS定义的一个数据输出函数,然后在技术指标或交易系统中调用此函数,图表中插入就会输出相应周期的数据,默认输出到F盘! Code: Function ff(Formula,abc) Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, f DIM pDate,pOpen,pHigh,pLow,pClose,pVolume,pOpenint Set History = Formula.ParentGrid.GetHistoryData() pDate =FormatDateTime(history.Date(Formula.IndexData),0) pOpen = history.Open(Formula.IndexData) pHigh = history.High(Formula.IndexData) pLow = history.Low(Formula.IndexData) pClose =history.Close(Formula.IndexData) pVolume=history.Volume(Formula.IndexData) pOpenint=history.Openint(Formula.IndexData) Set fso = CreateObject("Scripting.FileSystemObject") ' 得到框架名称为"Technic",窗格名称为"Main"的窗格对象 Set Grid = Technic.GetGridByName("Main") '得到该窗格所对应的动态行情对象 Set ReportData = Grid.GetReportData() e= "f:\"+ReportData.Label+ ".txt" Set f = fso.OpenTextFile(e, ForAppending, True) f.Write(pDate) f.Write(",") f.Write(CSng(pOpen)) f.Write(",") f.Write(CSng(pHigh)) f.Write(",") f.Write(CSng(pLow)) f.Write(",") f.Write(CSng(pClose)) f.Write(",") f.Write(CSng(pVolume)) f.Write(",") f.Write(CSng(pOpenint)) f.WriteBlankLines(1) f.Close '系统会在解释公式时的每个周期都会调用此函数一遍,因此设计时应该注重程序的执行效率,不要重复的执行一些没必要的代码 ff=0 End Function
谢谢你,我已经实现了. 能保存tick数据到文本文件. 现在的问题是, 对于IB外盘数据, 很多都是北京时间凌晨5之前收盘. marketdata.GetMinuteData()只能获得一天的ticks 所以每天下班回家后, 执行脚本, 只能拿到半天的tick data Superview, ytweiwei能不能更改 marketdata.GetMinuteData()函数为抓两天的分笔数据. 这样就能在一天内任何时间都可以拿天一整天的分笔数据. 省的凌晨3点到5点收盘时, 保存一天的外盘分笔数据.
一点浅见: 感觉所有数据应该可以选择直接用交易所时间, 另外图标显示也应可选择交易所所在时区, 这样就摆脱用户时区的限制, 也不应跟装机时的时区有任何关系。 Quote tracker这一点做得挺好的。