Wednesday, February 25, 2009

Writing Experts for MetaTrader. Lesson number 19

Education MQL II. Lesson 19

Hello dear readers! Not one reader asked me to rewrite with Omega or Metastoka AMA (adaptive moving average) Kaufman. In this issue we write this is an indicator.

Algorithm

A detailed description of the indicator and its algorithm is described by Constantine Kopyrkinym, in his article "The dynamic moving averages. Part 2," the journal "Modern Trading. Article in PDF (475 kB), will be able to download here: http://fxtest.ru/AMA.pdf

AMA Kaufman is an exponentially smoothed moving average, the rate averaging only she is not constant, but varies depending on the situation in the market. If Flat rate increases averaging to AMA retarded and did not give false signals, the trend is reduced and the AMA quickly, without delay (relatively) reacts to changes in prices.

For those who have not downloaded the article, briefly describe the algorithm. The indicator is the period, it determines the number of bars involved in the calculation of the indicator. During this period, is determined, the so-called "efficiency of movement." "Efficiency of movement is calculated as the ratio of displacement to the trajectory of prices over the period. The maximum value of the coefficient of 1, minimum 0. For example, between 10 and last 10 Candles "bychi, in this case the" efficiency movement "will be equal to 1. Consider the trajectory of the closing prices. In the two indicator set period of averaging (EMA), the big and small. These limits will vary between AMA according to the "efficiency of movement." Ie minimum period for the values 1 and 0 to the maximum.

In the external variables will make between AMA, boundary periods (large and small EMA) and the number of bars in which the indicator will be displayed.

Conclusion

The usefulness of this indicator of different people say different, but his idea is so simple and logical that this technical tool gives me great sympathy. I am sure that there will be traders who will have this indicator for the soul.

/ * [[
Name: = AMA
Author: = forextimes
Link: = fxtest.ru
Notes: = AMA Kaufman
Separate Window: = No
First Color: = Blue
First Draw Type: = Line
First Symbol: = 217
Use Second Data: = No
Second Color: = Red
Second Draw Type: = Line
Second Symbol: = 218
]] * /
inputs: n (10), fastMA (2), slowMA (30), Nbars (500);
Variable: shift (0), k (0), Noise (0), signal (0), i (0), AMA (0), ssc (0), er (0), AMA1 (0);

SetLoopCount (0);
/ / Loop from first bar to current bar (with shift = 0)
AMA1 = c [Nbars]; / / this is the first artificial value indicator, the price equates to the closure of

For shift = Nbars Downto 0 Begin / / calculate start znachacheny indicator

signal = 0, / / moving
Noise = 0, / / path

signal = abs (c [shift]-c [shift + n-1]) / / calculate the displacement

for i = shift To shift + n-1 Begin
Noise = Noise + abs (c [i]-c [i +1]); / / calculate the trajectory
end;

er = signal / Noise; / /
ssc = er * (2 / (1 + fastMA) -2 / (1 + slowMA)) + (2 / (1 + slowMA ));// amending smoothing constant

AMA = (c [shift] * ssc * ssc) + GetIndexValue (shift +1) * (1-ssc * ssc); / / value of AMA
if shift = Nbars then AMA = (c [shift] * ssc * ssc) + AMA1 * (1-ssc * ssc); / / zngachenie AMA for the first bar

SetIndexValue (shift, AMA); / / writes value to the array indicator AMA

End;




Company «Fxtest»
Halhalyan Arthur
Technical support for traders
artur@fxtest.ru

No comments: