MQL4|String Data Type(string)

※記事内に広告を含む場合があります。

Usage The string data type is used to represent text strings. For example, strings are necessary for usernames, messages, and currency pair symbols. In MQL4, ASCII strings up to 255 characters can be stored.

Size The size of a string type is variable, with the actual string data being stored elsewhere in memory. As a pointer, it has a size of 8 bytes.

Value Range String types can hold ASCII characters ranging from 0 to 255. This means each character is represented by one byte.

Usage Example Below is an example of using the string type. This example stores strings in variables and outputs them as messages.

void OnStart() {
    // Define strings
    string greeting = "Hello, World!";
    string currencyPair = "USDJPY";

    // Output strings
    Print(greeting);
    Print("The current currency pair is " + currencyPair + ".");

    // Concatenate strings
    string fullMessage = greeting + " The current currency pair is " + currencyPair + ".";
    Print(fullMessage);
}

In this code, the following steps are taken to use the string type:

  1. Define string variables greeting and currencyPair, assigning values to them.
  2. Use the Print function to output the contents of greeting and currencyPair.
  3. Use the + operator to concatenate multiple strings and store them in a new string fullMessage.
  4. Output the contents of fullMessage with the Print function.

Thus, the string type is very convenient for handling text data and is widely used when text manipulation or display is required.

※記事内に広告を含む場合があります。
ベアちゃん@東京シストレ: One of Japan's oldest MetaTrader FX automated trading developers 🔧. With over 15 years of professional experience, he boasts achievements such as winning first place in the Tradency Tournament '15 🥇 and being the runner-up in the 3rd EA-1 Grand Prix 🥈. He has also appeared on Radio Nikkei and is currently active as an executive of Trilogy Corporation (a registered investment advisory and agency business) [Registration number: 372, Director of the Kinki Finance Bureau, Ministry of Finance]. To join the board of Trilogy Corporation, he underwent a rigorous personal examination by the Kinki Finance Bureau, and his name is now registered with the Kinki Finance Bureau. Becoming an executive officer of a registered investment advisory and agency business requires passing this stringent personal examination. Utilizing his extensive knowledge as a former senior design engineer, he provides insights into the development of high-performance Expert Advisors (EAs), the latest trading technologies, and market analysis. He delivers professional strategies and tips to traders aiming to optimize their FX trading and maximize profits.

This website uses cookies.