//| SimpleSymbolInfoDouble.mq4 |
//| Copyright 2023, Crowdcompany UG |
//| |
#property copyright “Copyright 2023, Crowdcompany UG”
#property link “”
#property version “1.00”
#property strict

//| Expert Advisor’s OnTick function |
void OnTick()
// 1. Initialization

// Get the symbol name for the current chart
string currentSymbol = _Symbol;

// 2. Retrieve Symbol Details

// Obtain the maximum lot size for the symbol
double maximumLotSize = SymbolInfoDouble(currentSymbol, SYMBOL_VOLUME_MAX);

// Obtain the minimum lot size for the symbol
double minimumLotSize = SymbolInfoDouble(currentSymbol, SYMBOL_VOLUME_MIN);

// Obtain the point size for the symbol
double pointSize = SymbolInfoDouble(currentSymbol, SYMBOL_POINT);

// 3. Display Symbol Details

// Print the retrieved symbol information to the terminal
Print(“Max lot size for “, currentSymbol, “: “, maximumLotSize);
Print(“Min lot size for “, currentSymbol, “: “, minimumLotSize);
Print(“Point Size for “, currentSymbol, “: “, pointSize);

// 4. Further Processing
// Placeholder for any additional data handling or calculations
// …

// 5. Trading Logic
// Placeholder for trading decisions based on the retrieved symbol data or other criteria
// …

The SymbolInfoDouble function in MQL4 is used to retrieve numerical data about a trading symbol. Depending on the identifier provided as the second parameter, this function can return various pieces of information about the specified symbol.

Let’s break down the code:

  1. Meta Information:
    • The lines at the very top (#property directives) provide meta-information about the script:
      • copyright: States the ownership of the script.
      • link: Provides a URL, likely to the developer’s website or the source of the script.
      • version: Indicates the version of the script.
      • strict: Enforces strict data type checking in the script, which can be helpful to avoid certain types of runtime errors.
  2. OnTick Function:
    • This function is executed on every incoming tick for the chart where the Expert Advisor (EA) is attached. A tick is essentially a price update.
  3. Initialization:
    • The script fetches the name of the current symbol (e.g., “EURUSD”) on which the EA is running and assigns it to the currentSymbol variable.
  4. Retrieve Symbol Details:
    • The script uses SymbolInfoDouble to gather three pieces of information about the currentSymbol:
      • maximumLotSize: The maximum lot size allowed for trades on this symbol.
      • minimumLotSize: The minimum lot size allowed for trades on this symbol.
      • pointSize: The point size (smallest change in price) of the symbol.
  5. Display Symbol Details:
    • The retrieved details are printed to the terminal’s log or journal using the Print function. This can be useful for debugging or just to know more about the trading conditions of the current symbol.
  6. Further Processing:
    • This section is a placeholder for any additional logic or data processing you might want to add.
  7. Trading Logic:
    • Another placeholder, this time for the core logic that would decide when and how to trade. This could be based on the retrieved symbol details or other criteria, but currently, it’s empty.

This is how you create an Expert Advisor that can retrieve and display some key information about a trading symbol in MetaTrader 4. This data can subsequently be used to make informed trading decisions, though the logic for such decisions isn’t provided in the given code.