Discussion of article "MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors"

 

New article MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors is published:

In order to obtain values of a built-in or custom indicator in an Expert Advisor, first its handle should be created using the corresponding function. Examples in the article show how to use this or that technical indicator while creating your own programs. The article describes indicators that are built n the MQL5 language. It is intended for those who don't have much experience in the development of trading strategies and offers simple and clear ways of working with indicators using the offered library of functions.

An Expert Advisor or indicator that doesn't use standard technical indicators in its code is rare. They are popular both for the beginners and advanced developers of trading strategies. It isn't difficult to understand the details of indicator creation; the aim of this article is to help with it. We will consider the use of the functions for working with built-in standard technical indicators.

Author: Sergey

 
useful article. :) waiting for trade operation's example.
 

Introduction to Technical Indicators (based on dailyfx aticle)

Trend Following

Trend following indicators were created to help traders trade currency pairs that are trending up or trending down. We have all heard the phrase “the trend is your friend.” These indicators can help point out the direction of the trend and can tell us if a trend actually exists.

Moving Averages

A Moving Average (MA for short) is a technical tool that averages a currency pair’s price over a period of time. The smoothing effect this has on the chart helps give a clearer indication on what direction the pair is moving… either up, down, or sideways. There are a variety of moving averages to choose from. Simple Moving Averages and Exponential Moving Averages are by far the most popular.

Ichimoku

Ichimoku is a complicated looking trend assistant that turns out to be much simpler than it initially appears. This Japanese indicator was created to be a standalone indicator that shows current trends, displays support/resistance levels, and indicates when a trend has likely reversed. Ichimoku roughly translates to “one glance” since it is meant to be a quick way to see how price is behaving on a chart.

ADX

The Average Direction Index takes a different method when it comes to analyzing trends. It won’t tell you whether price is trending up or down, but it will tell you if price is trending or is ranging. This makes it the perfect filter for either a range or trend strategy by making sure you are trading based on current market conditions.

Oscillators

Oscillators give traders an idea of how momentum is developing on a specific currency pair. When price treks higher, oscillators will move higher. When price drops lower, oscillators will move lower. Whenever oscillators reach an extreme level, it might be time to look for price to turn back around to the mean. However, just because an oscillator reaches “Overbought” or “Oversold” levels doesn’t mean we should try to call a top or a bottom. Oscillators can stay at extreme levels for a long time, so we need to wait for a valid sign before trading.

RSI

The Relative Strength Index is arguably the most popular oscillator out there. A big component of its formula is the ratio between the average gain and average loss over the last 14 periods. The RSI is bound between 0 – 100 and is considered overbought above 70 and oversold when below 30. Traders generally look to sell when 70 is crossed from above and look to buy when 30 is crossed from below.

Stochastics

Stochastics offer traders a different approach to calculate price oscillations by tracking how far the current price is from the lowest low of the last X number of periods. This distance is then divided by the difference between the high and low price during the same number of periods. The line created, %K, is then used to create a moving average, %D, that is placed directly on top of the %K. The result is two lines moving between 0-100 with overbought and oversold levels at 80 and 20. Traders can wait for the two lines to crosses while in overbought or oversold territories or they can look for divergence between the stochastic and the actual price before placing a trade.

CCI

The Commodity Channel Index is different than many oscillators in that there is no limit to how high or how low it can go. It uses 0 as a centerline with overbought and oversold levels starting at +100 and -100. Traders look to sell breaks below +100 and buy breaks above -100. To see some real examples of the CCI in action,

MACD

The Moving Average Convergence/Divergence tracks the difference between two EMA lines, the 12 EMA and 26 EMA. The difference between the two EMAs is then drawn on a sub-chart (called the MACD line) with a 9 EMA drawn directly on top of it (called the Signal line). Traders then look to buy when the MACD line crosses above the signal line and look to sell when the MACD line crosses below the signal line. There are also opportunities to trade divergence between the MACD and price.

Volatility

Volatility measures how large the upswings and downswings are for a particular currency pair. When a currency’s price fluctuates wildly up and down it is said to have high volatility. Whereas a currency pair that does not fluctuate as much is said to have low volatility. It’s important to note how volatile a currency pair is before opening a trade, so we can take that into consideration with picking our trade size and stop and limit levels.

Bollinger Bands®

Bollinger Bands print 3 lines directly on top of the price chart. The middle ‘band’ is a 20-period simple moving average with an upper and low ‘band’ that are drawn 2 standard deviations above and below the 20 MA. This means the more volatile the pair is, the wider the outer bands will become, giving the Bollinger Bands the ability to be used universally across currency pairs no matter how they behave. The wider the bands, the more volatile the pair. Most common uses for Bollinger Bands are trying to trade double tops/bottoms that hit an upper or lower band or looking to trade bounces off an outer band in the direction of the overall trend.
Bollinger Bands® is a registered trademark of John Bollinger.

ATR

The Average True Range tells us the average distance between the high and low price over the last X number of bars (typically 14). This indicator is presented in pips where the higher the ATR gets, the more volatile the pair, and vice versa. This makes it a perfect tool to measure volatility and also can be a huge help when selecting where we should set our stop losses.

Support/Resistance

Pivot Points

Being one of the older technical indicators, Pivot Points are one of the most widely used in all markets including equities, commodities, and Forex. They are created using a formula composed of high, low and close prices for the previous period. There is a central pivot line and subsequent support lines and resistance lines surrounding it. Traders use these lines as potential support and resistance levels, levels that price might have a difficult time breaking through.

Donchian Channels

Price channels or Donchian Channels are lines above and below recent price action that show the high and low prices over an extended period of time These lines can then act as support or resistance if price comes into contact with them again. A common use for Donchian channels is trading a break of a line in the direction of the overall trend. This strategy was made famous by Richard Dennis’ Turtle Traders where Dennis took everyday people and was able to successfully teach them how to trade futures based on price channels.

Introduction to Technical Indicators
Introduction to Technical Indicators
  • Rob Pasche
  • www.dailyfx.com
The first time I opened a charting package and viewed all the available indicators, I felt completely overwhelmed. It looked like an endless list of terms written in a different language. Attempting to learn what all of them did seemed like a near impossible task, but over time, I did learn how many indicators can be helpful with my trading...
 

Hello Sergey,


I'm used to MT4 and starting to get involved with MT5.


Your article on https://www.mql5.com/en/articles/31      is one of the few with a clear structure and highly appreciated.


I copied your code partially and want to see/check custom indicator values in an EA.


This variation on built in indicators works fine:


OnInit part: MA_handle=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE);


OnTick Part: CopyBuffer(MA_handle,0,0,100,MA); ArraySetAsSeries(MA,true); Comment(MA[0]); the Comment shows the current MA value


---


now when using / replacing the iMA by MA_handle=iCustom(NULL,0,"ParabolicSAR", 0.04, 0.5 );


or my own indicator I get "-1" so even the built in Parabolic isn't adressed correctly ?!


I'd be very thankful for hints how to solve this.


---


Btw: my CustomIndicator I'd like to check in the next step has 5 inputs (A-E) and 3 buffers

OnInit part should probably be: MA_handle=iCustom(NULL, 0, "Indic. Name",A,B,C,D,E);

MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors
  • 2010.03.18
  • Sergey Pavlov
  • www.mql5.com
In order to obtain values of a built-in or custom indicator in an Expert Advisor, first its handle should be created using the corresponding function. Examples in the article show how to use this or that technical indicator while creating your own programs. The article describes indicators that are built n the MQL5 language. It is intended for those who don't have much experience in the development of trading strategies and offers simple and clear ways of working with indicators using the offered library of functions.
 

Excellent reference article. Helped me a lot! :)

 
I am irritated by the ArraySetAsSeries() inside the Ontick(). It should suffice to set it once, no?
Reason: