Research and development of high-frequency trading algorithm--moving average algorithm

Source: Internet
Author: User

Today, consider the application of the common EMA algorithm. In various trading software, we can often see MA indicator,EMA indicator and SMA indicator.

First explain SMA Two semantics, if you are directly searching for SMA indicators in Baidu, refers to a weighted exponential average; however, to query the "simple moving average" Baidu gives the abbreviation is SMA. Therefore, in order to be clear, science, this article uses "Wikipedia" the statement, its explanation is as follows:

MA : Also known as " moving averages " , moving averages can smooth short-term fluctuations, reflecting long-term trends or cycles. Mathematics , the moving average can be considered a convolution . to the author's understanding, it can be thoughtthat MA is a similar curve collectively.

SMA: Simple Moving average (simply moving Average,SMA) is a continuous The arithmetic mean of N days. The indicator also has a MA value that you see in common software.

ema: exponential moving average (exponential moving Average,EMA or EWMA ) is based on exponential type decrements the weighted moving average. The weighted influence of each value decreases exponentially with time, and the more recent data weighting is heavier, the older data is given a certain weighted value . As I understand it, the indicator definition is the same as the EMA referred to in common software . The image features are as follows:

WMA: weighted moving average (Weighted moving Average,WMA) means that individual data is multiplied when the average is calculated in a technical analysis, the most recent value of N- day WMA is multiplied by the n, th , and n-1 by different numerical values. , and so on, until 0. The image of the indicator is as follows:

by comparing EMA and WMA images, it is not difficult to find, EMA with the development of time, its attenuation is more obvious, can be more sensitive to reflect the trend of change. Therefore, in the common software, there will be more use of SMA (MA) and EMA.

Let's go to the main body of the book and say a bunch of hard-to-understand concepts, and talk about the application of these indicators and the problem.

we often see on TV and on the Internet the so-called "EMA Gold fork" and "moving average dead fork". The diagram is as follows (short cycle line: EMA:21, Long cycle line Ma:50):

The mathematical analysis is as follows:

When the short-period moving averages wear long cycle lines, the overall trend is declining and can be sold.

When the short-period moving averages wear long cycle lines, the overall trend is long and can be bought.

from this, the viewer is not difficult to find that the short-period moving average uses the Ema Line, the reason is that the EMA algorithm itself will result in the closer to the current time of the EMA value, the more severe attenuation, so that the closer the value of the real value, But it does not reach its true value (crossing: The Limit in calculus).

However, the long-period moving average uses MA Line, the reason is that the SMA value is based on the arithmetic average worth, without any weighting, which can ensure that the long line is not affected by the small K - ray fluctuations, and can continue to change.

It can be said that the use of long and short averages to chase each other's decision-making method, in most cases is applicable, but also is a more commonly used in financial transactions algorithm. But in some cases, this method can cause you to lose money more than a small amount! The situation is as follows:

through, crossing not hard to find, the current K Line in a short period of time similar to sinusoidal fluctuations, short-period moving averages and long-period moving averages will be frequent cross-over, in this case, basically every time will accompany some money, because the MA algorithm is the hindsight, so there is this situation, Either stop trading immediately, or find some short-cycle indicators to interpret to reduce the number of trades. So what kind of indicators need to be adopted and how to control them? And listen to tell ...

Note: No matter what kind of MA Line, in the case of long period comparison, will become more smooth, so that the software automatically determine whether the curve has an extreme point, providing operability. The algorithm is simple, as follows: (C #)

double[] data = new DOUBLE[100];

The principle is that the slope on both sides of the extreme point is multiplied by less than 0

if ((Data[i]-data[i-1]) * (Data[i+1]-data[i]) <0)

{

Extreme points appear

}

Scientists

Email:[email protected]

:43175692

Research and development of high-frequency trading algorithm--moving average algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.