In a script designed to loop through every available symbol and log the information available:
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);
So far, so good, I get a list of Symbol list positions printed. However, on attempting to call the corresponding SymbolName(),
mySymbol = SymbolName(i, false);
there is no further print output from the next line:
Print(mySymbol);
The output being as follows:
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
As you can see, there are no error codes, just a line of empty output before uninitialisation... This is the rest of the code for the sake of completeness, although not currently at issue:
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());
}
Any thoughts gratefully received
Just a thought, have a look at:
https://docs.mql4.com/files/filereadstring
It looks like you open the file but then you have to use the command FileReadString
in order to extract the Symbolname
from the CSV file. Of course, the Symbolname
has to be in the CSV.
lol - of course - thanks