Language 4 from MetaQuotes (MQL4)
The ability of traders to perform operations in the Forex market is significantly enhanced by such applications.
Name: images (2).png Views: 7 Size: 8.8 KB
MetaQuotes Language 4 is a high-level object-oriented programming language based on the popular C++ programming language's concepts. The MQL4 language's flexibility allows users to create complex programs with a large number of calculations while maintaining precise control over almost all trading robot and indicator parameters.

MQL4 has built-in functions for managing trading orders, as well as the basic indicators required for analyzing current and historical quotes. All of these features of the MetaQuotes Language 4 make it possible to create applications that can perform Forex market operations and thus completely replace a trader.

A Trading Robot (Expert Advisor) is a software program that allows for automated market analysis and Forex trading.
A Custom Indicator is a tool that can be used to analyze market conditions. Trading operations are not carried out by indicators. This type of instrument, unlike built-in technical indicators, can be programmed to carry out any analytical algorithm.

A script is a small program that is run only once to accomplish a specific task. A script can, for example, delete all objects from the chart, close all orders, or place a series of pending orders for an open position.
A library is a collection of functions that have been customized. It's designed to keep track of and distribute frequently used components of custom applications.
In MT4, how do you insert the symbol?
Custom financial instruments can now be created directly from the terminal. You can now create any symbol, configure its settings, import your price data into the symbol, and view its charts using the new option.
Creating Your Own Symbol
Use the context menu of the "Market Watch" window to open the symbol management window, then select "Create Custom Symbol":
Name: terminal_1__4.png Views: 7 Size: 31.5 KB
Symbol parameters can be configured in a large number of ways. The documentation contains a complete list of parameters as well as descriptions for each. By copying and modifying the parameters of any similar instrument, you can quickly configure your custom symbol. In the "Copy from" field, choose an existing symbol.
The custom symbol's name must not be identical to the names of symbols provided by the brokers. If you connect to a server that already has a symbol with the same name, the custom symbol will be overwritten.
There are also commands for importing and exporting parameters here. Custom symbols can be shared or transferred between terminals with ease. JSON text files are used to save configurations.

Custom Symbols:
Keeping Track of Them
In a separate Custom group, all symbols are displayed. If you need to change or remove a symbol, use MPPthe list's context menu:

The Price History is being imported.
Any text file can be used to import price data into your custom symbol. Go to the "Bars" tab after selecting a symbol.

Set the required parameters in the import dialog after specifying the path to the file:

In a text file, a separator is a character that separates the elements.

Columns and rows to skip during import the number of columns (from left to right) and rows (from top to bottom) to skip during the import.

Shift is a term that refers to a change in time that occurs over the course of several hours. When importing data from a different time zone, this option is selected.

Only rows highlighted in the row view area will be imported if selected only. While pressing Ctrl or Shift on your keyboard, you can use your mouse to highlight rows.

The following is the format for a file with 1-minute bars: TickVolume Volume Spread Date Time Open High Low Close TickVolume Volume Spread As an illustration:

Custom Symbols are a great way to express yourself creatively.

See also: Wide range of InstaForex technical indicators.

The use of custom symbols is similar to the use of broker-provided instruments. The Market Watch window displays custom symbols; you can open charts for these symbols and apply indicators and analytical objects to them. It is not possible to trade custom symbols.

Putting Strategies to the Test with Custom Symbols
In the strategy tester, custom symbols can be used to test trading robots and indicators. This enables strategy optimization even for financial symbols that a broker is unable to provide at the moment. All you have to do now is import the history correctly and set up the custom symbol properties.
The strategy tester automatically uses available cross rates when calculating the margin and profit. Assume we've created the AUDCAD.custom symbol with the Forex margin calculation method and a USD account currency. In this case, the tester looks for the required symbols in the order listed below, based on the name of the Forex symbol:
Name: terminal_1_2__3.png Views: 7 Size: 25.6 KB

First, the symbols of the AUDUSD.custom (for calculating the margin) and USDCAD.custom (for calculating the trade profit) forms are searched for.
If any of these symbols are missing, the first symbol that corresponds to the required currency pairs by name is searched for (AUDUSD and USDCAD respectively). The symbols AUDUSD.b and NZDUSD.b, for example, have been discovered. This implies that their rates will be used to determine the margin and profit.
Other types of margin calculations (Futures and Stock Exchange) necessitate the use of a currency pair to convert the instrument currency into the deposit currency. Assume we've created a custom symbol with GBP as the profit and margin currency and CHF as the deposit currency. In this case, the following is the order in which the search for testing symbols is carried out:
It is checked for the presence of a trading symbol that corresponds to GBPCHF (GBP vs CHF).
If no such symbol exists, the first trading symbol that corresponds to GBPCHF by its name, such as GBPCHF.b or GBPCHF.def, is used.
Selects a symbol in the Market Watch window or removes a symbol from the window.
bool SymbolSelect(
string name, // symbol name
bool select // add or remove
[in] Symbol name.
[in] Switch. If the value is false, a symbol should be removed from MarketWatch, otherwise a symbol should be selected in this window. A symbol can't be removed if the symbol chart is open, or there are open orders for this symbol.
Return Value
In case of failure returns false.

To get symbol data using functions for accessing timeseries and indicators, make sure that the symbol exists in the MarketWatch window. If the symbols is not available in Market watch, enable it using the SymbolSelect(symbol_name, true) function before you request the data.

The symbol can be hidden from MarketWatch after 10 minutes since the last access to the symbol history, i.e. since the call of functions like iOpen(), iHigh(), CopyTime() etc. This is due to the fact that the terminal stores symbol data for 10 minutes since the last access to them; after that unused data are automatically deleted from the terminal memory.

In MQL4, we're working on a symbol selection and navigation utility.
A brief introduction
The most time-consuming aspects of trading, according to experienced traders, are not opening and tracking positions, but rather selecting symbols and looking for entry points.

Of course, if you only work with a few symbols, these aren't major issues. However, if you have hundreds of stocks and dozens of Forex symbols in your trading toolkit, finding suitable entry points could take several hours.

In this article, we'll create an EA that will make finding stocks easier. The EA is expected to assist in three ways:

Try Forex indicators in MT4 with $1000 No Deposit Bonus now!

Its purpose is to pre-filter stocks and provide us with a list of those that meet our criteria; it should make navigation through the generated stock list easier; and it should display additional information that will help us make an informed decision.

EA template in its initial form
Initially, we will build the EA using MQL5. However, because many brokers still do not offer MetaTrader 5 accounts, we will re-develop the EA at the end of the article to make it compatible with MetaTrader 4.

When creating an EA, we use this template to register the timer. Every second, our timer starts counting down. This indicates that the standard OnTimer function should be called once every second.

#property strict is the only string that differs from a typical template generated by the MQL5 wizard. This string is required for the EA to function properly in MetaTrader 4. We include it in our template ahead of time because it has no significant effect on MetaTrader 5.
The following standard functions will be used:

OnInit: on the chart, display the buttons of trading instruments that meet our criteria;
Remove the timer and all graphical objects created by the EA in OnDeinit;

OnTimer: the timer is used to determine the number of clicks on graphical objects on the EA-created chart;
OnChartEvent: the reaction to clicking on graphical objects created on the chart where the EA is running.
The CArrayString type object will be used to store the list of symbols that meet our criteria. As a result, please attach the MQH file to our EA along with the object description:

#include ArraysArrayString.mqh> #include ArraysArrayString.mqh> #include ArraysArrayString.m
To work with charts, we'll need to use the CChart type object. Let's also include a definition for it:

#include ChartsChart.mqh> #include ChartsChart.mqh> #include ChartsChart.mqh> #include
All of this happens after the #property block of strings at the start of our template, outside of any functions.

The width and height of all of the buttons created by the EA must then be determined. After the #include block of strings, make these values into constants by specifying them:

BTN HEIGHT is a variable that needs to be defined (20)
BTN WIDTH is a variable that can be defined (100)
The inputs will be used to manage the EA. Let's take a look at them so we can figure out what functionality we'll be implementing later in the article:

input bool noSYMBmarketWath=true; / Hide if not in the Market Watch; sinput string delimeter 01=""; / - Filtration settings - input bool noSYMBmarketWath=""; /
input bool noSYMBwithPOS=true; / Hide if there are positions input ValueOfSpread hide SPREAD=spread b1; / Hide if there is a spread input uint hide PRICE HIGH=0; / Hide if the price is higher input uint hide PRICE LOW=0; / Hide if the price is lower input bool hideProhibites=true; / Hi Hide if ATR is less than the set value in dollars double hideATRcents=0.00; / Show if there is an open time input double hideATRcents=0.00; / Show if there is an open time input double hideATRcents=0.00; / Hide if ATR is less than the set value in
delimeter 02="" is a sinput string. / - Chart preferences - input bool addInfoWatch=false; / Add the chart to the Market Watch

See also: Wide range of InstaForex technical indicators.

viewCandle=true; / Open candlestick charts with input bool viewCandle=true;
viewVolumes=true; input bool viewVolumes=true; / Show tick volumes
input bool showInfoSymbol=true; / Display movement information input bool showNameSymbol=true; / Display symbol name
We can see that two of the inputs have a custom type right away. As a result, before the inputs, we'll include the definitions for these types. Enumerations make up both of the custom types.

The ValueOfSpread enumeration specifies the conditions that can apply to a spread value for symbols that the EA will display:

spread no,/No spread b05,/ > 0.05 percent spread b1,/ > 0.1 percent spread b15,/ > 0.15 percent spread l15,/ 0.15 percent spread l1,/ 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent 0.1 percent
A spread of more than 0.1 percent of the price is considered high. As a result, by default, we will only show symbols with a spread of less than 0.1 percent. As a result, in the case of a spread parameter, the Hide value is greater than 0.1 percent. However, if your broker's list of such symbols is insufficient, you can set this parameter to a different value.

The StartHour enumeration contains a list of the major times when some markets are open:

hour any, /Any time hour 9am, / 9 am hour 10am, / 10 am hour 4pm, / 4 pm hour 0am, / Midnight; enum StartHour hour any, /Any time hour 9am, / 9 am hour 10am, / 10 am hour 4pm, / 4 pm hour 0am, / Midnight;

You may visit instaForex for more details