a simple question ,someone must know the answer.

 

I want programmatically got every tradeable symbol in my mql4 soft.

I have ever seen someone done this before.

I am sure its possible to do that.

was these information store in a array or something.

could anyone tell me ?

 
Ma Yuliang:

I want programmatically got every tradeable symbol in my mql4 soft.

I have ever seen someone done this before.

I am sure its possible to do that.

was these information store in a array or something.

could anyone tell me ?


By using Market Info. See here for documentation and here for a code example of how to do it. Note the use of the "true/false" modifier to either restrict the list to only symbols in the Market Watch window or all symbols

Getting Market Information - MQL4 Documentation
  • docs.mql4.com
Getting Market Information - MQL4 Documentation
 
Stuart Browne:


By using Market Info. See here for documentation and here for a code example of how to do it. Note the use of the "true/false" modifier to either restrict the list to only symbols in the Market Watch window or all symbols

thanks a lot this is exact what I want.

I rewrite this code and got the trade allowed symbol list.

void OnStart()
  {

   string ListSymbols,symbol;int count;
   for(int i=0;i<SymbolsTotal(false);i++)
     {
      symbol=SymbolName(i,false);
      if(MarketInfo(symbol,MODE_SPREAD))
        {
         ListSymbols=StringConcatenate(ListSymbols,symbol,",");
         count++;
        }
     }
   MessageBox(count);
   MessageBox(ListSymbols);

  }
 
Ma Yuliang:

thanks a lot this is exact what I want.

I rewrite this code and got the trade allowed symbol list.

Welcome :)
 

Is the following "if-condition" to check a symbol a traceable one?

if(MarketInfo(symbol,MODE_SPREAD))  

My ecn account has symbols with and without the suffix "." (For example, EURUSD and EURUSD.)

While it is able to trade with all symbols which have ".", it is unable to trade with others.

So I suggest checking the suffix depending on the account type as well. 

Sorry if my comment is nonsense. 

 

that does not make sense.

MarketInfo(symbol,MODE_SPREAD)

returns the spread value.

so

spread=MarketInfo(symbol,MODE_SPREAD);
 
Marco vd Heijden:

that does not make sense.

returns the spread value.

so

Thanks for your comment. 

I know this, but in the context, I think Stuart Browne used this spread checking to confirm if a symbol is a trade allowed symbol.

If this is not his purpose, so why should we add the check for the spread in the code? 

Please explain to me. 

 

your question is unclear to me.

if you want to find out if there is a "." suffix you can add

StringFind(..
to search for it in the symbolname.
 

Thanks for reply and sorry for making you feel frustrated.

I just wondered why Mr. Stuart Browne implemented the code for getting the spread of each symbol,

because it seems not to be necessary here. 

 

I am not frustrated at all it's just that you can do many things in many different ways and everybody has got their own way of doing things.

I hope you can fix the code so that it does what you want it to do, if not feel free to post another message we are here to help each other (get filthy rich).

haha :)

 
ThanhHP:

Thanks for your comment. 

I know this, but in the context, I think Stuart Browne used this spread checking to confirm if a symbol is a trade allowed symbol.

If this is not his purpose, so why should we add the check for the spread in the code? 

Please explain to me. 

 

I didn't write the original code, I just linked to someone else's forum post that had written the code.

The original code didn't have any mention of spread. The original poster modified the code I linked to and added the spread check. No idea why.