What is the best way to deal with the filter coefficients? - page 4

 

Sorry to be amateurish, but are digital filters like SATL FATL etc. close to what you do, or from another field?

I understand it's something in electronics. What is the philosophy and theoretical validity of applying them to quotes?

 

For signal processing, see Sophocles J. Orfanidis, Optimum Signal Processing (and Introduction to Signal Processing)

 
Maxim Dmitrievsky:

Sorry for being amateurish, but are digital filters like SATL FATL etc. close to what you do, or from another field?

I take it it's something of electronics. What is the philosophy and theoretical validity of being able to apply them to quotes?


Can you give me a link to a description of these types of filters? Then I would be able to answer clearly. I did not find a description in the article on a cursory reading.

I make a class for filters with finite impulse response FIR or FIR in English. And what type and parameters they will have is determined solely by the coefficients, the algorithm is the same for all.

I consider coefficients for elliptic filters, as they are the shortest, therefore they will have the least delays.

About philosophy and validity - it makes no difference what to filter, electrical signals, quotes or any other data. The job of the filter is to remove unnecessary frequencies. For example, LPF crushes upper frequencies, in time domain we get smoothing of quotes, because high frequency noise is killed. I posted charts where it can be clearly seen. The same Simple MA mouving is a common FIR filter but not very effective. I took a detailed look at it in the article.

 
Alexey Volchanskiy:


Can you give me a link to a description of these types of filters? Then I would be able to answer clearly. I did not find any description in the article on a cursory reading.

I make a class for filters with finite impulse response FIR or FIR in English. And what type and parameters they will have is determined solely by coefficients, the algorithm is the same for all.

I consider coefficients for elliptic filters, as they are the shortest, therefore they will have the least delays.

About philosophy and validity - it makes no difference what to filter, electrical signals, quotes or any other data. The job of the filter is to remove unnecessary frequencies. For example, LPF crushes upper frequencies, in time domain we get smoothing of quotes, because high frequency noise is killed. I posted charts where it can be clearly seen. The same Simple MA mouving is a common FIR filter but not very effective. I've covered it in detail in the article.


But there, the link to the article was inserted by itself and it deals with this very issue.

https://www.mql5.com/ru/articles/32

Практическая реализация цифровых фильтров на MQL5 для начинающих
Практическая реализация цифровых фильтров на MQL5 для начинающих
  • 2010.03.19
  • Nikolay Kositsin
  • www.mql5.com
Идее цифровой фильтрации сигналов посвящаются достаточно объёмные темы обсуждения на форумах по построению торговых систем. В этой статье автор знакомит с процессом превращения кода более простого индикатора SMA из своей статьи "Пользовательские индикаторы в MQL5 для начинающих" в код гораздо более сложного универсального цифрового фильтра. В ней также изложены простейшие приёмы замены текста в коде и методика получения простейших навыков по исправлению ошибок программирования.
 
Quantum:

For signal processing there are books: Sophocles J. Orfanidis, Optimum Signal Processing (and Introduction to Signal Processing)


Interesting that there are many examples, though all with pointers. A la

/* cfir1.c - FIR filter implemented with circular delay-line buffer */

void wrap();

double cfir1(M, h, w, p, x)
double *h, *w, **p, x;
int M;
{                        
       int i;
       double y;

       *(*p)-- = x;
       wrap(M, w, p);                          /* \(p\) now points to \(s\sb{M}\) */

       for (y=0, h+=M, i=M; i>=0; i--) {       /* \(h\) starts at \(h\sb{M}\) */
              y += (*h--) * (*(*p)--);
              wrap(M, w, p);
              }

       return y;
}

I have done this so far, this is from the example, without classes. Inm_Coeff[] we need to load coefficients.

#define  TICK_BUF_SIZE       0x1000              // 4096
#define  TICK_BUF_MAX_IDX    (TICK_BUF_SIZE - 1) // 0xFFF
#define  OUT_BUF_SIZE        0x10000             // 65536
#define  OUT_BUF_MAX_IDX     (OUT_BUF_SIZE - 1)  // 0xFFFF   

double  m_TickBuf[TICK_BUF_SIZE]; // ring-buffer for ticks store
double  m_OutBuf[OUT_BUF_SIZE];   // output ring-buffer
double  m_Coeff[];                // coefficient array
int     m_CoeffSize;              // size of m_Coeff  
int     m_TickBufIdx;             // index of new tick placed in m_TickBuf
int     m_OutBufIdx;              // index of new tick placed in m_OutBuf

//+------------------------------------------------------------------+
//| filter one tick                                                                 |
//+------------------------------------------------------------------+
double  FilterTick(double tick)
  {
   static double acc;
   static int tbIdx;
   acc=0;
   tbIdx=m_TickBufIdx;
   m_TickBuf[m_TickBufIdx]=tick;
   if(m_TickBufIdx==0)
      m_TickBufIdx=TICK_BUF_MAX_IDX;
   else
      m_TickBufIdx--;
// filter in cycle "for""
   for(int n=0; n<m_CoeffSize; n++)
     {
      acc+=m_TickBuf[tbIdx++]*m_Coeff[n];
      tbIdx &=TICK_BUF_MAX_IDX; 
      /* it was little optimization instead if
      if(tbIdx > TICK_BUF_MAX_IDX)
         tbIdx = 0;*/
     }
   m_OutBuf[m_OutBufIdx++]=acc;
   m_OutBufIdx &=OUT_BUF_MAX_IDX;
   return acc;
  }
 
Maxim Dmitrievsky:

And there, the link to the article was inserted by itself; it is exactly about this point.


That is what I was talking about. Here is the formula of FIR filter that I use myself. But I've already written - it all depends on the coefficients. Yes, they are given, but without any description, so I can not judge. But there is an advertisement of the company )).

I'm referring to this piece of the article

----------

For example, you could try to build code in MQL5 for a digital filter like Finware's FATL.

In general terms the formula for calculating a digital filter is:

FILTER = SUM (K(i) * CLOSE (i), FilterPeriod)

where:

SUM - sum;

K(i) - weighting factor;

CLOSE (i) - closing price of the current bar;

FilterPeriod - number of bars for averaging.

 
Alexey Volchanskiy:


This is what I was talking about. Here is the formula of FIR filter I use myself. But I have already written - everything depends on coefficients. Yes, they are given, but without any description, so I can't judge right away. But there is an advertisement of the company )).

I'm referring to this piece of the article

----------

For example, you could try to build code in MQL5 for a digital filter like Finware's FATL.

In general terms the formula for calculating a digital filter is:

FILTER = SUM (K(i) * CLOSE (i), FilterPeriod)

where:

SUM - sum;

K(i) - weighting factor;

CLOSE (i) - closing price of the current bar;

FilterPeriod - number of bars for averaging.


I see, so it's the same topic in a different interpretation
 
Maxim Dmitrievsky:

I see, so it's the same subject in another interpretation.


Well, you can't think of anything else)) FIR filter is tremendously simple - quotes from the input buffer are sequentially multiplied by the array of coefficients, it all adds up, we obtain the output tick. If we deal with ticks, we will obtain an output tick. Or bar, if we work with Close.

That's why it's ridiculous to say that a firm has developed a revolutionary filter for quote analysis). Revolutions have long been in other fields.

 
Alexey Volchanskiy:


Well, you can't think of anything else here)) FIR filter is very simple - quotes from the input buffer are multiplied by an array of coefficients, it all adds up and obtains the output tick. If we deal with ticks, we will obtain an output tick. Or bar, if we work with Close.

That's why it's ridiculous to say that a firm has developed a revolutionary filter for quote analysis). Revolutions have long been in other fields.


Yes, several years ago this subject was advertised to traders as a new revolutionary discovery of super genius scientists.)
 
Maxim Dmitrievsky:

Yes, I remember a few years ago this topic was advertised to traders as a new revolutionary discovery of super genius scientists.)

They used to recruit people for training. Well, everyone earns as much as he or she can...