Download MetaTrader 5

a simple question ,someone must know the answer.

To add comments, please log in or register
Ma Yuliang
269
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 ?

Stuart Browne
6244
Stuart Browne  
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
Ma Yuliang
269
Ma Yuliang  
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);

  }
Stuart Browne
6244
Stuart Browne  
Ma Yuliang:

thanks a lot this is exact what I want.

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

Welcome :)
Thanh Hong Phuoc
162
Thanh Hong Phuoc  

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. 

Marco vd Heijden
Moderator
5350
Marco vd Heijden  

that does not make sense.

MarketInfo(symbol,MODE_SPREAD)

returns the spread value.

so

spread=MarketInfo(symbol,MODE_SPREAD);
Thanh Hong Phuoc
162
Thanh Hong Phuoc  
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. 

Marco vd Heijden
Moderator
5350
Marco vd Heijden  

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.
Thanh Hong Phuoc
162
Thanh Hong Phuoc  

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. 

Marco vd Heijden
Moderator
5350
Marco vd Heijden  

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 :)

Stuart Browne
6244
Stuart Browne  
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. 

To add comments, please log in or register