get list of all symbols running in mt4 programatically

 

hello ;

 i want to get list of all receiving quotes symbols programatiaclly..Can i do this?

 
Use the Search and you can find it . . I have posted about such code before.
 
RaptorUK:
Use the Search and you can find it . . I have posted about such code before.
can u provide me link?
 
ankit29030:
can u provide me link?
Yes i can . . .  I will have to search for it first . . . would you like a coffee while you wait ?
 
RaptorUK:
Yes i can . . .  I will have to search for it first . . . would you like a coffee while you wait ?

actually i searched that on google but no results...its shows only my post..
 
ankit29030: actually i searched that on google but no results...its shows only my post..
You didn't try very hard. Follow the first link from google would have got you to RaptorUK's post of AllMarketData.

int      FindSymbols(string& symbols[]){     // Get list of all tradeable pairs.
   #define FNAME "symbols.raw"
   int      handle=FileOpenHistory(FNAME, FILE_BIN | FILE_READ);
   if(handle<1){                                               DisableTrading(
      "Unable to open file"+FNAME+", error: "+GetLastError());    return(0);  }
   #define  RAW_RECORD_SIZE   1936
   #define  RAW_SYMBOL_SIZE   12
// #define  RAW_DESCR_SIZE    75
      #define  RAW_SKIP_DESCR    1924  // 1936-12
//    #define  RAW_SKIP_REMAN    1849  // 1936-12-75
   int      nRecords=FileSize(handle) / RAW_RECORD_SIZE;
   if(ArrayResize(symbols, nRecords) <= 0){                    DisableTrading(
      "ArrayResize(Symbols, "+nRecords+") Failed: " + GetLastError() );
      FileClose(handle);                                          return(0);  }
   for(int iRec=0; iRec < nRecords; iRec++){
      // "AUDCAD<NUL><NUL><NUL><NUL><NUL><NUL>"
      symbols[iRec]  = FileReadString(handle, RAW_SYMBOL_SIZE);
      FileSeek(handle, RAW_SKIP_DESCR, SEEK_CUR);     // goto the next record
      // "Auzzie Dollar  vs. Canadian Dollar<NUL><NUL><NUL>..."
      // dsc[nRec]   = FileReadString(handle, 75);
      // FileSeek(handle, RAW_SKIP_REMAN, SEEK_CUR);  // goto the next record
   }
   FileClose(handle);
   return(nRecords);
}  // FindSymbols
string   symbol.prefix, symbol.infix, symbol.postfix; // Export to symbolCross.
void OnInitCurrencies(){
   string   brokerSymbols[];  int nSymbols = FindSymbols(brokerSymbols);
                              if (nSymbols <= 0)                        return;
   //{ isolate prefix, infix, and postfix extra characters and base/quote
   // Broker's use a variety of nameing patterns: EURUSD, EURUSDm, "EURUSD.",
   // "EURUSD..", "EUR.USD", "EUR/USD", "EURUSD.stp", "EURUSDct" at least.
   #define iPREFIX 0
   int      iBase = iPREFIX - 1;
   for(int iPair = 0; true; iPair = (iPair+1) % nSymbols){
      if(      iPair == 0){   iBase++;
         int   testChar = StringGetChar(brokerSymbols[iPair], iBase);         }
      else  if(testChar != StringGetChar(brokerSymbols[iPair], iBase))  break;
   }
   int      iInfix = iBase + 3, iQuote = iInfix - 1;
   for(iPair = 0; true; iPair = (iPair+1) % nSymbols){
      if(      iPair == 0){   iQuote++;
               testChar = StringGetChar(brokerSymbols[iPair], iQuote);        }
      else  if(testChar != StringGetChar(brokerSymbols[iPair], iQuote)) break;
   }
   int   iPosfix  = iQuote + 3,  nChar = StringLen(market.pair);
   symbol.prefix  = ""; if(iBase  > iPREFIX) // count=0 treated as ALL!
   symbol.prefix  = StringSubstr(market.pair, iPREFIX, iBase  - iPREFIX);
   symbol.infix   = ""; if(iQuote > iInfix)
   symbol.infix   = StringSubstr(market.pair, iInfix,  iQuote - iInfix);
   symbol.postfix = ""; if(nChar  > iPosfix)
   symbol.postfix = StringSubstr(market.pair, iPosfix, nChar  - iPosfix);
:
 

Just do it;-)

int getAvailableCurrencyPairs(string& availableCurrencyPairs[])
{
//---   
   bool selected = false;
   const int symbolsCount = SymbolsTotal(selected);
   int currencypairsCount;
   ArrayResize(availableCurrencyPairs, symbolsCount);
   int idxCurrencyPair = 0;
   for(int idxSymbol = 0; idxSymbol < symbolsCount; idxSymbol++)
     {      
         string symbol = SymbolName(idxSymbol, selected);
         string firstChar = StringSubstr(symbol, 0, 1);
         if(firstChar != "#" && StringLen(symbol) == 6)
           {        
               availableCurrencyPairs[idxCurrencyPair++] = symbol; 
           } 
     }
     currencypairsCount = idxCurrencyPair;
     ArrayResize(availableCurrencyPairs, currencypairsCount);
     return currencypairsCount;
}
Files:
Reason: