Skip to content
All library documents

Accessing Symbol Data and Properties with the CStrategy CSymbol Class

Article MQL5 articles

Summary

This article describes the CSymbol class in the CStrategy MQL5 trading engine, which gathers access to instrument data in a dedicated object called WS, for Working Symbol. It explains how the class provides OHLCV series, quotes, market depth, and symbol properties such as trading constraints. Separating this functionality from the core strategy class is presented as a way to keep strategy code manageable, especially when working with multiple instruments.

Examples show how a strategy can read a previous bar’s high, convert a tick-size step into a price distance for a stop order, and find the bar corresponding to a position’s opening time to apply a holding-period exit. The article also describes a demonstration that uses properties across six futures symbols to build an interest-rate profile. The output is presented as an example rather than a general trading result, and the author cautions that quotes for required contracts must be available and preloaded. The focus is software architecture and symbol-data access, not a validated trading strategy.

Key ideas

  • The CSymbol class centralizes access to symbol quotes, properties, and time series through the WS object.
  • Separating instrument access from the main strategy class is intended to simplify strategy code.
  • The StepToPrice method converts a number of symbol price steps into a price distance for order placement.
  • IndexByTime can map a position opening time to a bar index for time-based position management.
  • The futures interest-rate profile example depends on having the required contract quotes loaded.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.