MarketInfo function

Hi folks,

We are going to complete our series of lessons that answer the question: "How to deal with currency pairs which are different than the current chart currency (The chart that hosts the expert advisor)? For example, how to make an expert advisor that can open Buy position of GBPUSD or USDCHF while the expert advisor is hosted on EURUSD chart?"

In the previous lesson we studied the Timeseries Access functions that enables us to access the price date of any chart (currency and timeframe) regardless of the chart that hosts the expert advisor. But they are not enough to write our expert advisor.

What's the Bid/Ask price we are going to use with OrderSend to open the order? We can't use the function Bid() and Ask() because they are returning the current currency Bid and Ask price.

Our magic function today is MarketInfo() function:

MarketInfo() function:

Syntax

double MarketInfo( string symbol, int type)

 

Description:

The MarketInfo() function is the function you need to retrieve various market data of the given currency, for example: the current Bid price of the currency, the current Ask price of the currency, the Swap value of Buy or Selling the currency and the number of digits the currency uses.

Note: A part of this data are stored in the Predefined Variables but this data is exclusive for the current chart and MarketInfo() function give us more data about the currency.

 

This function can return the following important data: