Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator

It begins with local variables , that are used in the function - their types and names.

We'll assume that it will trade only one financial instrument. It leads to the execution of OnBookEvent function. 

The StopLoss variable is used to temporarily store the Stop Loss price of opened position. The StopLoss current value for the opened position is determined using the PositionGetDouble function, that has an only one parameter - the identifier of the position property.

MetaTrader 5 Help 

Why should you refer to a MetaTrader 5 tutorial? In order to meet the rising demands of people wanting to perfect themselves with MetaTrader 5 .

The trading platform provides all the necessary tools for Expert Advisor development: Mobile Trading Smartphones and tablets are indispensable in trading when you are away from your computer.

You will certainly appreciate the functionality of the mobile trading platforms that include the full support for the trading functions, broad analytical capabilities with technical indicators and other graphical objects.

Of course, all these features are available from anywhere in the world 24 hours a day. Use the mobile platform to read financial news and internal emails, as well as for instant messaging with the participants of the most popular website for traders MQL5.

Additional Services The platform provides powerful trading tools and a variety of additional services. Social trading is available through the Signals service.

This is an easy way to copy deals of experienced traders. Deinit event happens when Expert Advisor or Indicator is terminated for example, after detaching from chart, closing Client Terminal, etc.

It leads to the execution of OnDeinit function. NewTick event happens when new quote for the current financial instrument is arrived used in Expert Advisors only. MQL4 equivalent - start function in Expert Advisors. MQL4 equivalent - start function in Indicators.

Trade event happens when the order is executed, modified or deleted, when the position is opened, modified or closed used in Expert Advisors only. In MQL4 there is no equivalent of this event and function. It leads to the execution of OnBookEvent function. ChartEvent event happens when user works with chart: In also happens during creation, movement or deletion of the graphic objects, etc.

It leads to the execution of OnChartEvent function. There is no equivalent of this event and function in MQL4. It leads to the execution of OnTimer function. In MQL4 there is no equivalent of this event and function, as well as a timer.

Before using the variables , it's necessary to specify the data type of each of them. It takes 1 byte of memory. It takes 2 bytes of memory. It takes 4 bytes of memory. It takes 8 bytes of memory. Usually it is used to store price data. It allows to specify a type of certain limited set of data. It's internal representation is 8-bytes structure, that contain the size of buffer with string and the pointer to that buffer.

It is necessary to choose the appropriate data type for the optimal performance and rational memory use. In MQL5 there is a new concept called structure. The structure combines the logically related data. Trading system The trading system, that is used in this article as an example, is based on the assumption, that European financial institutions are opened in the morning, and later, the economic events are published in USA, that leads to the trend of EURUSD.

The chart period isn't important, but I recommend to use the minute bars, because the whole day or its part is visible at once, so it's very convenient for the observation. At 7 AM server time Buy Stop and Sell Stop pending orders are placed at distance of one point beyond the price range of the current day.

For Buy Stop pending orders the spread is taken into account. The StopLoss levels are placed on the opposite sides of the range. After execution, StopLoss order is moved to simple moving average, but only if it's profitable. The benefit of this type of trailing compared with the classical Trailing Stop is following: On the other hand it leads to position closure when the trend ends and flat movement begins.

The simple moving average is calculated using minute chart data and has averaging period equal to The profit level depends on the current market volatility. To determine market volatility, the Average True Range ATR indicator with period equal to 5 is applied to the daily chart is used.

So, it shows the average daily range of the past week. To determine the Take Profit level value for the long position, we will add the value of the ATR indicator to the minimal price of the current day. The same for the short positions: The order is not placed if the order price value is beyond the StopLoss and TakeProfit levels.

After 7 PM server time all pending orders are deleted and aren't placed this day the open positions are still trailed until closing. Writing an indicator Let's write an indicator, that shows the profit levels of trade system described above. If the first symbol in a line is " ", it mean that this string is a preprocessor directive. Directives are used to specify additional program properties , to declare constants , to include header files and imported functions.

Note that after preprocessor directives there are no semicolon ; symbols. It uses the values" property description "of Average True Range ATR indicator, calculated" property description "on daily price data. Indicator values are calculated" property description "using maximal and minimal price values per day. When indicator is running this information looks as follows: It's necessary to specify indicators position: It can be done by specifying one of the properties: In our case, there are two lines, each of them has its own buffer - an array with the data that will be plotted.

There are many other drawing styles. You can define the color by specifying the brightness of its three RGB components or by using the predefined colors , for example, Red, Green, Blue, White, etc. The line styles are: Using the input modifier, let's specify the external variables you can specify their values after launching the indicator , their type and default values: On a global level that is visible to all functions , we will specify variables and their types , that will be used by different functions of our indicator.

We will use dynamic arrays i. The handle of built-in technical indicator will be stored in the hATR variable. Indicator handle is necessary to use the indicator. The first parameter defines the index of indicator's buffer, the ordering starts from 0.

The second parameter specifies an array, assigned to indicator's buffer. The third parameter specifies the type of data, stored in the indicator's buffer: The third parameter is the averaging period of the ATR indicator. The OnCalculate function is called right after the end of OnInit function execution and every time after the new quote arrival for the current symbol.

There are two ways of calling this function. Main Menu The main menu contains almost all the commands and functions that can be executed in the trading platform. It provides access to operations with charts, analytical tools, platform settings and other features.

The main menu consists of the following items: Toolbars The platform has three built-in toolbars: Standard, Line Studies and Periodicity. The toolbars contain duplicated commands and functions of the main menu. However, the toolbars are customizable, and you can add the most frequently used controls there.

Market Watch The Market Watch window provides access to the price data of financial instruments: Contract specifications and one-click trading features can also be accessed from this window.

Navigator The Navigator allows switching between accounts and provides functions for running trading robots and indicators. It contains a list of applications purchased from the Market and downloaded from the Code Base. From the navigator, users can rent a virtual platform to provide round-the-clock operation of Expert Advisors and trading Signals. Chart The essence of technical analysis is studying price charts of financial instruments using technical indicators and analytical objects.

 

63 Responses to “Indicator Tutorial for MetaTrader 5” 

This section contains basic information you need to know to get started with the platform. The trading platform provides a - Getting Started - MetaTrader 5 Help.

MT5 TUTORIALS | how to trade with metatrader 5 | metatrader 5 | how to use metatrader 5 guide. Metatrader5 is the best and patest Trading Platform from the makers of Metatrader 4 "metaquotes" with. The Trading Platform is the trader's working tool, providing all the necessary features for a successful online trading. It - MetaTrader 5 Help. 

More Info

2017 Best Broker

Why should you refer to a MetaTrader 5 tutorial? In order to meet the rising demands of people wanting to perfect themselves with MetaTrader 5 . Alpari MetaTrader 5 Trading Metatrader 5 Overview Tutorial. Home MT5 Brokers Alpari MetaTrader 5 Trading | MT5 Forex Broker. MT5 Brokers; Alpari MetaTrader 5.

MetaTrader 5 Tutorial and Basics for Beginners and Newbies. MetaTrader 5 Tutorial: How To Use In Binary Options-Forex Trading MetaTrader 5 provides an array of opportunities for a pool of actions .

More Info
© lokersumbagut.ga 2018