Metatrader 4 Digital Filters Article

Example on using Metatrader 4 Digital Filters (EUR/USD)

This is not a scientific research paper, just an example on using Low Frequency Filters and Trend Line Momentum indicators.

Let's consider EUR/USD pair in the D1 timeframe. Save the quotations in .csv format and open one quotation in the spectral analyzer Digital Methods Generator (Copyright © 2004-2005, Sergey Iljukhin http://fx.qrz.ru/)

 

metatrader 4 digital filters

The figure shows the following peaks: 87,  48,  27, 24, 21, 17.5,  12, 14.5, 7, 4 bars (days).

 

We believe that the primary EUR/USD cycle has a period of 87 trade days (107.17 days according to Vladimir Kravchuk's articles).

1/2 of the primary cycle - 48 trade days

1/3 of the primary cycle - 27 trade days

1/4 of the primary cycle - 21 trade day

1/6 of the primary cycle - 14.5 trade days etc.

 

This is important! To achieve a more precise result it is highly recommended to view the currency spectrum in several different timeframes (you can generate a timeframe of any size using a free indicator Period_Converter_Opt.mq4). 

We also recommend to choose the areas where the distribution of time series converges to normal (is quasi-stationary).  Check for the ergodicity of the sample using the moving average and the moving average dispersion.  

Now let's configure the Low Frequency Filters indicator that is similar to FATL and SATL. Open the source code and you will easily find the required spot.  

// Filtr 1

extern int FType_1=0; 

extern int P1_1=85;    

extern int D1_1=80;

extern int A1_1=60;

extern int P2_1=0;

extern int D2_1=0;

extern int A2_1=0;

extern double Ripple_1=0.001;

extern int Delay_1=0;

 

DLL Parametrs

 

Parameters

Type

Description

Value

1

Filter type

ByVal Integer (int)

Type of filter:

 

0 - LPF (FATL/SATL/KGLP)  

 

1 - HPF (KGHP)  

 

2 - BPF (RBCI/KGBP)  

 

3 - RBF (KGBS)  

Numeric Value (Integer >=0)

2

P1

ByVal Integer (int)

Pass band cutoff P1, bar

Numeric Value (Integer >=1)

3

D1

ByVal Integer (int)

Stop band cutoff D1, bar

Numeric Value (Integer >=1)

4

A1

ByVal Integer (int)

Attenuation in pass band À1, dB

Numeric Value (Integer >=1)

5

P2

ByVal Integer (int)

Pass band cutoff P2, bar

Numeric Value (Integer >=1)

6

D2

ByVal Integer (int)

Stop band cutoff D2, bar

Numeric Value (Integer >=1)

7

A2

ByVal Integer (int)

Attenuation in pass band À2, dB

Numeric Value (Integer >=1)

8

Ripple

ByVal Double (double)

Ripple in pass band dB

Numeric Value (Real Number >=0)

9

Delay

ByVal Integer (int)

Delay, bar

Numeric Value (Integer >=0)

10

FilterBuffer

ByRef Double[] (* double)

Address of calculated coefficients

Static 1500 elements

 

You can set up to 7 filters in this indicator.

// Filtr 2 - these are parameters for filter 2 and so on up to // Filtr 7 respectively. 

(This is not the limit; you can increase the number of the filters.) 

Go back to the first filter's settings for obtained primary cycle of 87 trade days.

So

extern int FType_1=0;  because we are building a low frequency filter

extern int P1_1=85;     the primary cycle's period is equal to 87 days (we recommend to set up the periods just a little shorter because the filter will cap all the periods from 0 to 87 and the period of 87 days will not be displayed too well; therefore we use 85)

 

extern int D1_1=65;   we select it in such a way that the filter's order should not exceed 1500 elements (that's a limitation of the dll); if the maximum value is used, the filter is faster but less smooth.

 

extern int A1_1=60;

extern int P2_1=0;

extern int D2_1=0;

extern int A2_1=0;

extern double Ripple_1=0.001;

extern int Delay_1=0;

 

 

Now we have a filter.

 

metatrader 4 digital filters

 

The other filters are configured in the same way.

metatrader 4 digital filters (fatl, satl, ftlm, stlm)

Let's have a look at the Trend Line Momentum (STLM, FTLM) indicator configuration.

 

Trend Line Momentum = Low Frequency Filters (fast, i.e. without delay extern int Delay_1=0;) - Frequency Filters (slow, i.e. with delay  extern int Delay_1=K;)

where K is an integer. In real life K is selected based upon the Nyquist frequency.  We recommend a trial and error method selection.

 

Find this spot in the Trend Line Momentum indicator source code:

 

 

//******************************************** Trend Line Momentum 1 *********

 

// Filtr 1 Parametrs

extern int FType_1=0;

extern int P1_1=85;

extern int D1_1=65;

extern int A1_1=60;

extern int P2_1=0;

extern int D2_1=0;

extern int A2_1=0;

extern double Ripple_1=0.001;

extern int Delay_1=0;

 

// Filtr 2 Parametrs

extern int FType_2=0;

extern int P1_2=85;

extern int D1_2=65;

extern int A1_2=60;

extern int P2_2=0;

extern int D2_2=0;

extern int A2_2=0;

extern double Ripple_2=0.001;

extern int Delay_2=8;

 

 

 

 

We see that the first filter's parameters // Filtr 1 are exactly the same as Low Frequency Filters indicator's first filter. The second filter's parameters // Filtr 2 are exactly the same as the first filter's except for the delay extern int Delay_2=8.

 

metatrader 4 digital filters (fatl, satl, ftlm, stlm) 

The other filters are configured in the same way.

 

Further, having defined the entry and exit points as the filter tendency, you can build an automatic trading system using our expert DF-exp.mq4.

 

The sell orders are hardcoded in the source code // check for short position (SELL) possibility

For buying // check for long position (BUY) possibility

For closing // should it be closed?

It should be noted that with our 2 indicators you can obtain other filters described in Vladimir Kravchuk's articles, besides these analogous to SATL, FATL, STLM, FTLM; just update the first line of the filter's parameters extern int FType_1=0;

 

 

0 - LPF (FATL/SATL/KGLP)  

 

1 - HPF (KGHP)  

 

 

2 - BPF (RBCI/KGBP)  

 

 

3 - RBF (KGBS)  

 

In building our trading systems we used only low frequency filters 0 - LPF (FATL/SATL/KGLP)

 

 

Boris Fesenko

BJF Trading Group


Happy to answer all your questions

Read Article: Example on using Digital Filters GBP/USD

 

 

ADD TO YOUR SOCIAL BOOKMARKS:

 

 
Sign up for our FREE weekly newsletter:

Forex trading involves substantial risk of loss and is not suitable for all investors. Read full disclosure.

email: support@fxstrategy.ca
Gain Capital / Forex.com acts as the clearing agent and counterparty to customers introduced by BJF Trading Group for an IB margined forex transactions. Gain Capital / Forex.com is a registered Futures Commission Merchant (FCM), regulated by the Commodity Futures Trading Commission (CFTC), and a member of the National Futures Association (NFA).

MQL4 Programming Service Payment Option

E-commerce services are provided by SWREG, Inc., an e-commerce reseller. Privacy Policy.

seo company toronto