- Getting available symbols and Market Watch lists
- Editing the Market Watch list
- Checking if a symbol exists
- Checking the symbol data relevance
- Getting the last tick of a symbol
- Schedules of trading and quoting sessions
- Symbol margin rates
- Overview of functions for getting symbol properties
- Checking symbol status
- Price type for building symbol charts
- Base, quote, and margin currencies of the instrument
- Price representation accuracy and change steps
- Permitted volumes of trading operations
- Trading permission
- Symbol trading conditions and order execution modes
- Margin requirements
- Pending order expiration rules
- Spreads and order distance from the current price
- Getting swap sizes
- Current market information (tick)
- Descriptive symbol properties
- Depth of Market
- Custom symbol properties
- Specific properties (stock exchange, derivatives, bonds)
Price type for building symbol charts
Bars on MetaTrader 5 price charts can be plotted based on Bid or Last prices, and the plotting type is indicated in the specification of each instrument. An MQL program can find this characteristic by calling the SymbolInfoInteger function for the SYMBOL_CHART_MODE property. The return value is a member of the ENUM_SYMBOL_CHART_MODE enumeration.
Identifier |
Description |
---|---|
SYMBOL_CHART_MODE_BID |
Bars are built at Bid prices |
SYMBOL_CHART_MODE_LAST |
Bars are built at Last prices |
The mode with Last prices is used for symbols traded on exchanges (as opposed to the decentralized Forex market), and the Depth of Market is available for such symbols. The depth of the market can be found based on the SYMBOL_TICKS_BOOKDEPTH property.
The SYMBOL_CHART_MODE property is useful for adjusting the signals of indicators or strategies that are built, for example, at the chart's Last prices, while orders will be executed "at the market price", that is, at Ask or Bid prices depending on direction.
Also, the price type is required when calculating bars of the custom instrument: if it depends on standard symbols, it may make sense to consider their settings by price type. When the user enters the formula of the synthetic instrument in the Custom Symbol window (opened by selecting Create Symbol in the Symbols dialogue), it is possible to select price types according to the specifications of the respective standard symbols used. However, when the calculation algorithm is formed in an MQL program, precisely it is responsible for the correct choice of the price type.
First, let's collect statistics on the use of Bid and Last prices to build charts on a specific account. This is what the script SymbolStatsByPriceType.mq5 will do.
const bool MarketWatchOnly = false;
|
Try it on different accounts (some may not have stock symbols). Here's what the result might look like:
Symbols in total: 52304
|
A more practical example is the indicator SymbolBidAskChart.mq5, designed to draw a diagram in the form of bars formed based on prices of the specified type. This will allow you to compare candlesticks of a chart that uses prices from the SYMBOL_CHART_MODE property for its construction with bars on an alternative price type. For example, you can see bars at the Bid price on the instrument chart at the price Last or get bars for the Ask price, which the standard terminal charts do not support.
As a basis for a new indicator, we will take a ready-made indicator IndDeltaVolume.mq5 presented in the section Waiting for data and managing visibility. In that indicator, we downloaded a tick history for a certain number of bars BarCount and calculated the delta of volumes, that is, separately buy and sell volumes. In the new indicator, we only need to replace the calculation algorithm with the search for Open, High, Low, and Close prices based on ticks inside each bar.
Indicator settings include four buffers and one bar chart (DRAW_BARS) displayed in the main window.
#property indicator_chart_window
|
The display as bars is chosen to make them easier to read when run over the main chart candlesticks so that both versions of each bar are visible.
The new ChartMode input parameter allows the user to select one of three price types (note that Ask is our addition compared to the standard set of elements in ENUM_SYMBOL_CHART_MODE).
enum ENUM_SYMBOL_CHART_MODE_EXTENDED
|
The former CalcDeltaVolume class changed its name to CalcCustomBars but remained almost unchanged. The differences include a new set of four buffers and the chartMode field which is initialized in the constructor from the input variable ChartMode.
class CalcCustomBars
|
Depending on the mode of chartMode, the auxiliary method price returns a specific price type from each tick.
protected:
|
Using the price method, we can easily implement the modification of the main calculation method calc which fills the buffers for the bar numbered i based on an array of ticks for this bar.
void calc(const int i, const MqlTick &ticks[], const int skip = 0)
|
The remaining fragments of the source code and the principles of their work correspond to the description of IndDeltaVolume.mq5.
In the OnInit handler, we additionally display the current price type of the chart and return a warning if the user decides to build an indicator based on the Last price type for the instrument where the Last is absent.
int OnInit()
|
Below is a screenshot of an instrument with the chart plotting mode based on the Last price; an indicator with the price type Bid is laid over the chart.
Indicator with bars at Bid prices on the chart at Last prices
It is also interesting to look at the bars for the Ask price running over a regular Bid price chart.
Indicator with bars at Ask prices on the chart at Bid prices
During hours of low liquidity, when the spread widens, you can see a significant difference between Bid and Ask charts.