Any integer representation for currency pairs?

Back to topics list To post a new topic, please log in or register
avatar
66
macpee 2016.03.24 14:43
 

Hello comrades, just as the integer values for OP_BUY, OP_SELL, OP_BUYLIMIT, OP_SELLLIMIT, OP_BUYSTOP and OP_SELLSTOP are 0, 1, 2, 3 and 4, respectively, are there integer values for the traded instruments. That is, integer values for GBPUSD, EURUSD, USDJPY, etc. The idea is to run through the mentioned instruments using their integer values in a loop such as in the following codes:


int extern IntendedInstrumentInteger;    \\ This value input as 11 say.
int i, FirstInstrumentInteger, LastInstrumentInteger;
void start()
{
for (i == FirstInstrumentInteger, i <= LastInstrumentInteger, i++) 
    {
     if (i == IntendedInstrumentInteger) 
         {
          Print ("Execute some codes");
         }
    }
}


If no such integer values exist, what is a good possible way to run through the currency pairs listed on the broker platform while searching for a particular one? Thank you in advance.

avatar
164
drazen64 2016.03.24 19:56 #
 

Use SymbolsTotal() and SymbolName() to loop through the list of the instruments.

Something like this:

bool all_symbols = true;

for(int i = 0; i < SymbolsTotal(all_symbols); i++)
{
  string instrument = SymbolName(i, all_symbols);
  // do something with a symbol name here
}

 

avatar
66
macpee 2016.03.24 20:36 #
 
macpee:
 Thank you @drazen64. I have been able to execute   Print("Symbol ",i, "is ", instrument);  using your codes, and hence I can now print all the instruments at a go. I must confess though that MQL4 has not expressed user-friendliness if this is the only way to return all instruments. Nevertheless, my problem has been solved.

avatar
13001
WHRoeder 2016.03.25 14:13 #
 
Do not trade multiple currencies in one EA
  • You can't use any predefined variables, can't use the tester, must poll (not OnTick,) and usually other problems.
  • Code it to trade the chart pair only. Look at the others if you must.
  • Then put it on other charts to trade the other pairs. Done.
avatar
66
macpee 2016.03.30 15:27 #
 
WHRoeder:
Do not trade multiple currencies in one EA
  • You can't use any predefined variables, can't use the tester, must poll (not OnTick,) and usually other problems.
  • Code it to trade the chart pair only. Look at the others if you must.
  • Then put it on other charts to trade the other pairs. Done.
Thank you for such advice @WHRoeder.
Back to topics list  

To add comments, please log in or register