要用到array函数吗
取数据用minutedata对象,是吗?写文件用哪个函数呢?
debugfile是用在后台策略上的,在vba策略中,只能使用filesystemobject对象了,这是我从网上搜索的代码,你自己参照代码就能搞定吧。
Dim fsObj, file
'写
Set fsObj = CreateObject("Scripting.FileSystemObject")
Set file = fsObj.CreateTextFile("c:\test.txt", True)
file.WriteLine ("test" )
file.Close
'读
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fileObj, fileInfo, retObj, strInfo, strPath As String
Set fileObj = CreateObject("Scripting.FileSystemObject")
strPath = "c:\test.txt"
Set fileInfo = fileObj.GetFile(strPath)
Set retObj = fileInfo.OpenAsTextStream(ForReading, TristateUseDefault)
strInfo = retObj.ReadLine
retObj.Close
由于金字塔不支持type,所以不知道如何建立struct啊
版主有什么好的思路吗????
读取MT4历史数据的范例
struct HistoryHeader
{
int version; // 基础版本
char copyright[64]; // 版权信息
char symbol[12]; // 证券
int period; // 周期类型
int digits; // 小数位数
time_t timesign; // 基础报时的创建
time_t last_sync; // 同步时间
int unused[13]; // 将来应用
}MTHSTHEAD;
#pragma pack(push,1)
struct RateInfo
{
time_t ctm;
double open;
double low;
double high;
double close;
double vol;
}MTHST;
#pragma pack(pop)
MTHSTHEAD hsthead;
MTHST kline;
CArray<MTHST, MTHST > akline;
CFile file;
if( file.Open( _T("USDCHF1440.hst"), CFile::modeRead ) )
{
file.SeekToBegin();
file.Read( &hsthead, sizeof(MTHSTHEAD) );
while( sizeof(MTHST) == file.Read( &kline, sizeof(MTHST) ) )
{
akline.Add(kline);
}
file.Close();
}