How to compare str and str in the string array ?

 
How to compare str and str in the string array ?
 
oxeno:
How to compare str and str in the string array ?

An array of something is just that something indexed by a number.

for

string string1= "dog";
string string2= "cat";

I am sure you would be happy to compare them

if( string1==string2 ){
   // do something
}

In an array it is no different

string stringArray[] = {"dog","cat","mouse","lion"};

then you would say

if( stringArray[0]==stringArray[1] ){
   // do stuff
}

see also

https://docs.mql4.com/basis/operations/relation

 
oxeno:
How to compare str and str in the string array ?


could you specify your question?

what do you want it for?

 
findmyself:


could you specify your question?

what do you want it for?


I trying to wor it out, if i cant would you please here again~,thanks all the same .

 
dabbler:

An array of something is just that something indexed by a number.

for

I am sure you would be happy to compare them

In an array it is no different

then you would say

see also

https://docs.mql4.com/basis/operations/relation

https://docs.mql4.com/basis/operations/relation I read it before .and I learned

NormalizeDouble()

there.

Thanks,i'lltry it out.

 
dabbler:

An array of something is just that something indexed by a number.

for

I am sure you would be happy to compare them

In an array it is no different

then you would say

see also

https://docs.mql4.com/basis/operations/relation




Now I am traverse string symbols[],and tell the result later .
    string symbols[]  = {"EURUSDpro","EURJPYpro","EURGBPpro",
                         "EURNZDpro","EURCZKpro","EURTRYpro",
                         "EURNOKpro","EURPLNpro","EURDKKpro",
                         "EURHUFpro","EURSEKpro","EURCADpro",
                         "EURAUDpro","EURCHFpro",
                         "USDJPYpro","USDCADpro","USDDKKpro",
                         "USDZARpro","USDCZKpro","USDHUFpro"
                         "USDSEKpro","USDTRYpro","USDSGDpro",
                         "USDNOKpro","USDPLNpro","USDMXNpro",
                         "AUDJPYpro","AUDCHFpro","AUDUSDpro",
                         "AUDCADpro","AUDNZDpro",
                         "GBPJPYpro","GBPCHFpro","GBPAUDpro",
                         "GBPCADpro","GBPUSDpro","GBPNZDpro",
                         "CADJPYpro","CADCHFpro",
                         "NZDUSDpro","NZDCHFpro","NZDCADpro",
                         "NZDJPYpro","SGDJPYpro",
                         "XAUUSDpro","XAUAUDpro","XAUCHFpro",
                         "XAUEURpro","XAUGBPpro","XAGUSDpro" };

 
oxeno:
Now I am traverse string symbols[],and tell the result later .

Why are you hard coding a list of symbols. That will only work on one broker's server. May not work on other servers and definitely other brokers.

There is a way to read all the symbols a broker supports.

 
WHRoeder:

Why are you hard coding a list of symbols. That will only work on one broker's server. May not work on other servers and definitely other brokers.

There is a way to read all the symbols a broker supports.


er...I can't find another way to do so ..

and all above is fail to reach my mine .

then can u tell me how to add an element into a new emty string array?

 
oxeno:



then can u tell me how to add an element into a new emty string array?

Think about it for a while. You know how to access element n in an array, it is theNameofYourArray[n].

Keep a count of the elements as you add them, then you will know where the last element is and therefore where to add the new one.

 

Just grab the first 6 letters with

string StringSubstr( string text, int start, int length=0) 
Extracts a substring from text string starting from the given position.
The function returns a copy of the extracted substring if possible, otherwise, 
it returns an empty string.
Parameters:
text   -   String from which the substring will be extracted. 
start   -   Substring starting index. Can be from 0 to StringLen(text)-1. 
length   -   Length of the substring extracted. If the parameter value 
exceeds or equals to 0 or the parameter is not specified, the substring will be 
extracted starting from the given position and up to the end of the string. 

Sample:
  string text="The quick brown dog jumps over the lazy fox";
  string substr=StringSubstr(text, 4, 5);
  // subtracted string is the "quick" word

 

If you're looking for difference between Standard vs Mini vs Macro accounts, you can try looking at:

Market information identifiers, used with MarketInfo() function.
It can be any of the following values:

Constant        Value  Description
MODE_MARGININIT 29     Initial margin requirements for 1 lot. 
Reason: