How do you algorithmise the detection of MA feed clusters? - page 11

 
Mikhail Toptunov:

So Moda is every third(x[2],x[5]...) or just x[2] is moda

Sorry, I don't understand it as... ( which corresponds to the maximum of the array pdf[i](the 4th argument of the function.) )

Something like this:

#include <Math\Stat\Math.mqh>
void OnStart()
{
  double a[] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.55, 0.56, 0.565, 0.57, 0.58, 0.59, 0.6, 0.7, 0.8, 0.9};
  double mode, eps = 0.01;
  mode = mode_calc(a, eps);
  Print("mode = ", mode);
}
//+------------------------------------------------------------------+
double mode_calc(double &a[], double eps)// вычисление моды для выборки a[] с точностью eps
{
  double x[], pdf[];
  MathSequence(MathMin(a), MathMax(a), eps, x);
  int n = ArraySize(x);
  ArrayResize(pdf, n);
  MathProbabilityDensityEmpirical(a, n, x, pdf);
  int ix = ArrayMaximum(pdf);
  return x[ix];
}
 
Maxim Kuznetsov:

In a straightforward way, without optimisations, matrices and complicated mathematics:

1. For the current bar, count all the MAs separately. We get SMA[N] array which contains values of maxima up to N

2. we create a heatmap[M] which covers prices from minimum=1.00000, each element is responsible for (e.g.) 10 points.

3. We fill this "raw" heatmap: we take each ma value and see which cell it refers to. index=(SMA[i]-minimum)/resolution. We increase the value of this cell hetmap[index]+=1.0

You can output the result to CSV and think

4. Smooth the "raw" heatmap values: start array smooth[] and read the average smotch[i]=average value of heatmap from i-window to i+window inclusive

5. The local maxima of smootch will indicate a "cluster of feeds". I hope you know how to look for maxima :-)

Points 1-5 can be mathematically decomposed and computed much faster, with a minimum of loops and extra arrays, but not necessarily more intuitive.


I don't understandhetmap[index],index - ( if 500 MA for example, and resolution=10 points ) to how much will it be?

Fuck and what isminimum=1.00000.

As I understand it :

In general, no way, it seems as if we need to compare the two nearest MAs, if less than 1, then write to hetmap[i ]

 
Dmitry Fedoseev:

How does this heat map fit in?

I'm sorry, I don't understand which side to approach then!

 
Mikhail Toptunov:

I'm sorry, I don't know which way to go then!

I think we should start by studying an ABC book.

 
Dmitry Fedoseev:

Seems you have to start by studying an ABC book.



That's what I could do, that's the best option!!! But that's ***.

 
Mikhail Toptunov:


Here's what I could do, it's the best option!!! But that's ***.

Where are the clusters marked there?

 
How will you look for clusters of points on a straight line?

The simplest thing is to calculate the average (density dljat).

This is the same here.
 
Went into deep meditation to search for the meaning of the word 'dljat'...
 
Dmitry Fedoseev:

Where are the clusters marked?

In general, it is necessary to calculate the moment of transition of one bundle to another, i.e. when the cluster changes movement.

The picture supposedly shows these moments at point 50ur phyb.

Maxim Kuznetsov:
How will you search for point clusters on a straight line?

The simplest thing is to calculate the average (density of dljats).

Here it is the same.

If (MA[i-1] - MA[i])+(MA[i] - MA[i+1])<0.005 then

within МА [i] zone (for example, +-10 values of indexes i), I look for the minimum value of MA

and write the parameters of the point of cluster into the class (create an object in the class)

identify the adjacent bundle (the bundle itself) specifically for the adjacent bar. I.e. I look through the class objects for closeness of a period and a bar.

and see the tendency of the bundle of objects

 

In general, I do this kind of act

void  medianaL0_0(const int rates_total,const datetime &time[])
  {
   double masPra[Pmax]; // хранение цены МА
   int masPer[Pmax]; // хранение Периода 
   CountPO=0;
   ArrayResize(PO,CountPO); 
   ZeroMemory(PO);
   for(int b=rates_total-Pmax; b<rates_total; b++)
     {
      for(int p=2; p<Pmax; p++) // отбор по периодам
        {
         masPra[p]=sm.d[p-1].m[b]; 
         masPer[p]=p;        
        }
      MathQuickSort(masPra,masPer,2,Pmax-1,1);
      medianaL0_2(masPra,masPer,b,time);
     }
  }

void medianaL0_2(const double &masPra[],const int &masPer[],int bar,const datetime &time[])
  {
   double m[Pmax],x=0,y=0;
   for(int i=5; i<Pmax-1; i++)
     {
      filter0_0(i);
      x=MathAbs(masPra[i-1]-masPra[i]); //MathSqrt
      y=MathAbs(masPra[i]-masPra[i+1]);
      int a=MathAbs(masPer[_ot]-masPer[i]);
      int b=MathAbs(masPer[i]-masPer[_do]);
      if(masPer[i]-masPer[i-1]<=_ot)//&&masPer[i+1]-masPer[i]<=_ot
         m[i]=x+y;
       else
          m[i]=-1;
     }
   medianaL0_3(masPra,masPer,bar,time,m);
  }

void medianaL0_3(const double &masPra[],const int &masPer[],int bar,const datetime &time[],const double &m[])
  {
   for(int i=5; i<Pmax-1; i++)
     {
      filter0_0(i);
      int z=ArrayMinimum(m,_ot,_do);
      if(m[z]<=0.005&&m[z]!=-1)
        {
         ArrayResize(PO,CountPO+1); 
         PO[CountPO].bar=bar;
         PO[CountPO].period=masPer[i];
         PO[CountPO].mediana=i;
         PO[CountPO].praceMA=masPra[i];
         PO[CountPO].time=time[bar];
         CountPO++;
        }
      i=i+_do;
     }
  }