Search for AllMarketDate in the Code Base. Use parts of its code to obtain a list of symbols.
Did you mean AllMarketData? I am aware of it, actually. It has a function that gets the symbols:
//+------------------------------------------------------------------+ //| AllMarketData.mq4 | //| Copyright © 2011, MGAlgorithmics | //| http://www.mgaforex.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, MGAlgorithmics" #property link "http://www.mgaforex.com" int FindSymbols() { int handle, i, r, TotalRecords; string fname, Sy, descr; //-----> fname = "symbols.raw"; handle=FileOpenHistory(fname, FILE_BIN | FILE_READ); if(handle<1) { Print("HTML Report generator - Unable to open file"+fname+", the last error is: ", GetLastError()); return(false); } TotalRecords=FileSize(handle) / 1936; ArrayResize(Symbols, TotalRecords); for(i=0; i<TotalRecords; i++) { Sy=FileReadString(handle, 12); descr=FileReadString(handle, 75); FileSeek(handle, 1849, SEEK_CUR); // goto the next record Symbols[r]=Sy; Descr[r]=descr; SyDigits[r]=MarketInfo(Sy,MODE_DIGITS); Spread[r]=MarketInfo(Sy,MODE_SPREAD); swap[r][LONG]=MarketInfo(Sy,MODE_SWAPLONG); swap[r][SHORT]=MarketInfo(Sy,MODE_SWAPSHORT); swap[r][TYPE]=MarketInfo(Sy,MODE_SWAPTYPE); Stop[r]=MarketInfo(Sy,MODE_STOPLEVEL); Lot[r][SIZE]=MarketInfo(Sy,MODE_LOTSIZE); Lot[r][MIN]= MarketInfo(Sy,MODE_MINLOT); Lot[r][LOTSTEP]=MarketInfo(Sy,MODE_LOTSTEP); Lot[r][MAXLOT]=MarketInfo(Sy,MODE_MAXLOT); Tick[r][VALUE]= MarketInfo(Sy,MODE_TICKVALUE); Tick[r][SIZE]=MarketInfo(Sy,MODE_TICKSIZE); Timing[r][STARTING]=MarketInfo(Sy,MODE_STARTING); Timing[r][EXPIRATION]=MarketInfo(Sy,MODE_EXPIRATION); Trade[r][ALLOWED]=MarketInfo(Sy,MODE_TRADEALLOWED); Trade[r][MODE]=MarketInfo(Sy,MODE_PROFITCALCMODE); if (Trade[r][MODE]>MAX) MAX=Trade[r][MODE]; // the script won't print the following items ... if you need them, amend yourself the PrintResult function below :) /*Margin[r][CALC]=MarketInfo(sSymbol,MODE_MARGINCALCMODE); Margin[r][INIT]=MarketInfo(sSymbol,MODE_MARGININIT); Margin[r][HEDGED]=MarketInfo(sSymbol,MODE_MARGINHEDGED); Margin[r][REQUIRED]=MarketInfo(sSymbol,MODE_MARGINREQUIRED); Freeze[r]=MarketInfo(sSymbol,MODE_FREEZELEVEL);*/ // a different index for the count can be useful if you want to filter some elements from the whole list r++; } FileClose(handle); return(TotalRecords); }
I don't understand the code completely, but can use it if there is no better way.
I attempted to modify the AllMarketData.mq4 code:
int start() { string SymbolArray[]; StoreSymbols(SymbolArray); Alert(SymbolArray[0]); } void StoreSymbols(string& SymbolArray[]) //no pointers in mql4 :( { int handle=FileOpenHistory("symbols.raw", FILE_BIN | FILE_READ); if(handle<1) { Print("Error Opening File: ", GetLastError()); return(false); } int TotalRecords=FileSize(handle) / 1936; string SymbolName; for(int i=0; i<TotalRecords; i++) { SymbolName =FileReadString(handle, 12); FileSeek(handle, 1849, SEEK_CUR); // goto the next record SymbolArray[i]=SymbolName; } FileClose(handle); return(TotalRecords); }
The alert is just blank, and I'm not sure what is wrong.
Does any one see mistakes in the code?
The alert is just blank, and I'm not sure what is wrong.
Does any one see mistakes in the code?
#1: Resize SymbolArray to be equal to number of TotalRecords.
#2: Adjust your FileSeek offset from 1849 to 1924 (because you aren't reading the symbol description like AllMarketData does).
See code below (modifications highlighted):
int StoreSymbols(string& SymbolArray[]) { int handle=FileOpenHistory("symbols.raw", FILE_BIN | FILE_READ); if(handle<1) { Print("Error Opening File: ", GetLastError()); return(false); } int TotalRecords=FileSize(handle) / 1936; ArrayResize(SymbolArray, TotalRecords); string SymbolName; for(int i=0; i<TotalRecords; i++) { SymbolName =FileReadString(handle, 12); FileSeek(handle, 1924, SEEK_CUR); // goto the next record SymbolArray[i]=SymbolName; } FileClose(handle); return(TotalRecords); }
What data are you trying to export? Price data? I tried to do this but eventually gave up battling with loading bars of symbols that are not loaded. Watch out for error 4066. I think even after getting the "all symbols" part working, it might stop you in your tracks
I just manually load up each chart, scroll back as far as I need and run my exporter script :(
#1: Resize SymbolArray to be equal to number of TotalRecords.
#2: Adjust your FileSeek offset from 1849 to 1924 (because you aren't reading the symbol description like AllMarketData does).
See code below (modifications highlighted):
Thanks alot Thirteen. Now the output is correct. I'm curious, how did you find the offset? When I looked at symbols.raw in notepad I didn't see the symbols the way it comes out in the output. I did see for example "EURCHF" in symbols.raw but my output when I write all the symbols array to a file appears as "EURCHF." -- which is how my broker writes it.
What data are you trying to export? Price data? I tried to do this but eventually gave up battling with loading bars of symbols that are not loaded. Watch out for error 4066. I think even after getting the "all symbols" part working, it might stop you in your tracks
I just manually load up each chart, scroll back as far as I need and run my exporter script :(
Thanks for the heads-up. I'll show you the code if I succeed.
What data are you trying to export? Price data?
This is a sample for one symbol:
20130906,16:00,0.9198,0.9212,0.9183,0.9198,743 20130906,17:00,0.9197,0.9214,0.9191,0.9194,464 20130906,18:00,0.9193,0.9205,0.9192,0.9203,220 20130906,19:00,0.9202,0.9202,0.9193,0.9194,141 20130906,20:00,0.9195,0.9196,0.9192,0.9194,74 20130906,21:00,0.9193,0.9197,0.9192,0.9194,69
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I wrote the custom indicator below that writes the chart data to a file for my other charting software to use. I have tested it and it seems to work. Now, I'm thinking of making it create files for all symbols instead of just the current chart.
Any ideas on how to accomplish that?
If I could get an array of all the symbols then I should be able adjust my code to do the job.
Btw, it would have been more convenient to just rewrite the file in start(), but my other charting software that is going to read the file will get confused sometimes. Not rewriting the file seems to work much better.
Please, any advice or comments on how to adjust the code and make it get the data of all symbols are welcome.