在旨在遍历每个可用符号并记录可用信息的脚本中:
int i, j, file_handle;
string InpDirectoryName, InpFileName, Textwrite, mySymbol;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
int MIIds[29]; // 0-28 market information type IDs
int ST;
MIIds[0] = 1;
MIIds[1] = 2;
MIIds[2] = 5;
for(i=3;i<=28; i++)
MIIds[i] = i+6;
ST = SymbolsTotal(false);
InpDirectoryName = "";
InpFileName = "Test.csv";
Textwrite = "";
file_handle=FileOpen(InpDirectoryName+InpFileName,FILE_READ|FILE_WRITE|FILE_CSV);
if(file_handle!=INVALID_HANDLE)
{
for(i=1;i<=ST; i++)
Print(i);
到目前为止,一切顺利,我得到了打印的“符号”列表位置的列表。 但是,在尝试调用相应的SymbolName()时,
mySymbol = SymbolName(i, false);
下一行没有进一步的打印输出:
Print(mySymbol);
输出如下:
0 12:29:56.630 Script test EURUSD,H4: loaded successfully
0 12:29:56.667 test EURUSD,H4: initialized
0 12:29:56.669 test EURUSD,H4: 1
...
0 12:29:56.670 test EURUSD,H4: 68
0 12:29:56.670 test EURUSD,H4:
0 12:29:56.670 test EURUSD,H4: uninit reason 0
0 12:29:56.676 Script test EURUSD,H4: removed
如您所见,没有错误代码,在未初始化之前只有一行空输出... 为了完整起见,这是其余的代码,尽管目前尚无争议:
SymbolSelect(mySymbol,true);
Textwrite = mySymbol;
for(j=0;i<=28; j++)
Textwrite = Textwrite + "," + MarketInfo(mySymbol,j);
FileWrite(file_handle,Textwrite);
FileClose(file_handle);
}
else Print("Operation FileOpen failed, error ",GetLastError());
}
感谢任何感想