-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSymbols.mq5
54 lines (47 loc) · 2.2 KB
/
getSymbols.mq5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//+------------------------------------------------------------------+
//| GetAllTickerbols.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Script program start function |
// Alireza December 2021
// This script export list of all tickers avialable for selected broker to a csv file with shortable attribute
//+------------------------------------------------------------------+
string Ticker, PatternLine;
string csvfile = "Symbols.csv";
void OnStart()
{
// Open output csv file
if (FileIsExist(csvfile))
{
FileDelete(csvfile);
};
int filepointer = FileOpen( csvfile , FILE_READ|FILE_WRITE|FILE_TXT|FILE_UNICODE);
//Number of all avialable Ticker including Options, Stock, Bonds, Forex, OTC, Commodity and etc
int nTickerAll = SymbolsTotal(false);
// wirte headers
PatternLine = "Ticker\tPath\tShortable\n";
FileSeek(filepointer , 0, SEEK_END);
FileWriteString(filepointer, PatternLine, StringLen(SYMBOL_PATH) );
printf("total number of tickers is " + IntegerToString(nTickerAll));
printf("==================================================================");
//Main Loop
while ( --nTickerAll>=0 && !IsStopped() )
{
ResetLastError();
Ticker = SymbolName(nTickerAll,false);
printf(Ticker + " , " + SymbolInfoString(Ticker , SYMBOL_PATH) + " , " + SymbolInfoInteger(Ticker , SYMBOL_TRADE_MODE) );
PatternLine = StringFormat(
"%s\t%s\t%d\n",
Ticker, SymbolInfoString(Ticker , SYMBOL_PATH), SymbolInfoInteger(Ticker , SYMBOL_TRADE_MODE)
);
FileWriteString(filepointer, PatternLine, StringLen(PatternLine) );
Comment("# ",nTickerAll," ",Ticker," DONE");
}
FileClose(filepointer);
}
//+------------------------------------------------------------------+