Detected Country () : English
Strings - codingforex.com

Welcome to CodingForex.Com!

Knowledge portal where you can learn how to create forex indicators and robot.

Click button below to choose level that suite you:

Strings

Level Active [2017-11-16 11:07:13] - by hillzx
Featured Image

Metatrader has several functions to process string data type, complete list and full explanation can be opened at official link MQL here. These functions include:

 

 

Function

Action

StringAdd

Adds a string to the end of another string

StringBufferLen

Returns the size of buffer allocated for the string

StringCompare

Compares two strings and returns 1 if the first string is greater than the second; 0 - if the strings are equal; -1 (minus 1) - if the first string is less than the second one

StringConcatenate

Forms a string of parameters passed

StringFill

Fills out a specified string by selected symbols

StringFind

Search for a substring in a string

StringGetCharacter

Returns the value of a number located in the specified string position

StringInit

Initializes string by specified symbols and provides the specified string length

StringLen

Returns the number of symbols in a string

StringReplace

Replaces all the found substrings of a string by a set sequence of symbols

StringSetCharacter

Returns a copy of a string with a changed value of a symbol in a specified position

StringSplit

Gets substrings by a specified separator from the specified string, returns the number of substrings obtained

StringSubstr

Extracts a substring from a text string starting from a specified position

StringToLower

Transforms all symbols of a selected string to lowercase

StringToUpper

Transforms all symbols of a selected string into capitals

StringTrimLeft

Cuts line feed characters, spaces and tabs in the left part of the string

StringTrimRight

Cuts line feed characters, spaces and tabs in the right part of the string

StringGetChar

Returns character (code) from the specified position in the string

StringSetChar

Returns the string copy with changed character in the specified position



The function marked yellow is a frequently used function, so you do not have to memorize all the formulas. Example of using the code:

 

//StringAdd
string a="halo";
string b="sobat";
StringAdd(a,b); // halosobat

//StringConcatenate
string text;
text=StringConcatenate("Margin bebas :", AccountFreeMargin(), " Waktu sekarang :", TimeToStr(TimeCurrent()));
Print(text);

//StringFind
for(int i=ObjectsTotal()-1; i>-1; i--)
{
  if(StringFind(ObjectName(i),"HiLLzXWavePLAY")>=0){ // Cari objek yang memiliki kata "HiLLzXWavePLAY" pada namanya
    ObjectDelete(ObjectName(i));
  }
}

//StringLen
int jumlah = StringLen("ABC"); //jumlah = 3

//StringSplit
string to_split="sarimin_pergi_ke_pasar";
string sep="_";
ushort u_sep;
string result[];
u_sep=StringGetCharacter(sep,0);
int k=StringSplit(to_split,u_sep,result);
Print(result[0]); // sarimin
Print(result[1]); // pergi
Print(result[2]); // ke
Print(result[3]); // pasar

//StringToLower
Print( StringToLower("Aku Anak Gembala") ); // aku anak gembala

//StringToUpper
Print( StringToUpper("Aku Anak Gembala") ); // AKU ANAK GEMBALA


Good luck, do not forget to share and follow our official facebook and youtube, happy trading!



Previous Article

Featured Image

Account Information

Next Article

Featured Image

Market Info




- Provided by HiLLzSoft Studio -