Numerical series density - page 6

 
-Aleks-:

I repeat the question - what window do you propose to average a numeric series?

What's the square in red in your screenshot?

Oh dear...

Well, shove the numeric values of the series into it with a shift to the right, if they fit.

You will get SMA and density

 
Renat Akhtyamov:

What's the square in red in your screenshot?

Oh dear...

Well, shove the numeric values of the series to the right, if they fit.

You'll get SMA and density.

The red shows the area of density of numbers in the numeric series, found according to the above algorithm. You want to shove the numeric values into the square with a shift to the right, but how do you find this square? Let's not talk about emotions, but numbers - there is a numeric series - show me how you find the red square, as on the screenshot.
 
-Aleks-:
The red color indicates the area of the density of numbers in the numeric series, found according to the above algorithm. You want to put numeric values into the square with a shift to the right, but how do you find this square? Let's not discuss emotions, but numbers - there is a numeric series - show me how you find the red square, as on the screenshot.

SMA period - whatever you want it to be

it is also a square

Have you even looked at the MA formula to begin with?

 
Renat Akhtyamov:

SMA period - whatever you want it to be

It's a square.

Have you even looked at the formula of MA to begin with?

I've already told you - if you think others are idiots, prove your intelligence in practice - give me a calculation and an algorithm.

 
-Aleks-:

I have already told you - if you think others are idiots, then prove your intelligence in practice - give a calculation and an algorithm.

And where is the saucer with the golden platter, where should I put it?

If you lacked a clue, I can only wish you success on this one!

 
Renat Akhtyamov:

and where's the saucer with the gold platter, where do I put it?

If you lacked a clue, I can only wish you success on this one!

Well, it is obvious now that you are unable to back up your fantasies with action.

Good luck finding another place to assert yourself!

 

Reproduce the algorithm up to the point of selecting groups of dense numbers. Next you need to check its actual performance as follows:

1. Change the initial data

2. save the result of selected numbers

3. Visualise the data


//+------------------------------------------------------------------+
//|                                             Test_FindOblast'.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                            https://www.mql5.com/ru/users/-aleks- |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com/ru/users/-aleks-"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   int massivSize=19; //размер массива  
   double Digit[19]=
     {
      10,
      20,
      30,
      40,
      50,
      51,
      52,
      53,
      54,
      60,
      70,
      80,
      120,
      150,
      190,
      210,
      223,
      232,
      260,
      250
     };

   double summDelta[19-1];
   int N=massivSize-1;//Количество оставшихся цифровых значений
   double avrMass=0;//Среднее значение массива дельт
   int SizeMass=0;//Узнаем размер массива
   int SizeMassDigit=0;//Узнаем размер массива

ArraySort(Digit,WHOLE_ARRAY,0,MODE_ASCEND);//Сортируем массив на случай, если значения не внесены в порядке возрастания

//-Фильтр
//1. Суммируем  последовательно две дельты и умножаем значение на два
   for(int i=1;i<massivSize;i++)
     {
      summDelta[i-1]=((Digit[i]-Digit[i-1])+(Digit[i+1]-Digit[i]))*2;
     }
   for(int i=0;i<massivSize-1;i++) printf("summDelta[%d] = %G",i,summDelta[i]);

//3. Составляем новый числовой ряд, если значение меньше среднего значения
//4. Повторяем пункт 2-3 пока числовой ряд не будет меньше половины первоначального ряда
   for(int Z=0;N>massivSize/2;Z++)
     {
      SizeMass=ArraySize(summDelta);//Узнаем размер массива
      SizeMassDigit=ArraySize(Digit);//Узнаем размер массива      
      avrMass=0;
      int NOL=0;
      int CalcZero=0;

//2. Находим среднее значение получившегося числового ряда
      for(int i=0;i<SizeMass;i++)
        {
         if(summDelta[i]!=0)avrMass=avrMass+summDelta[i];
         else NOL++;
        }
      avrMass=avrMass/(SizeMass-NOL);
      Print("Среднее значение получившегося числового ряда ",Z,"=",avrMass);

//Обнуляем отфильтрованные значения массива summDelta
      for(int i=0;i<SizeMass;i++)
        {
         if(summDelta[i]>avrMass)
           {
            summDelta[i]=0;
            N--;
           }
        }
      for(int i=0;i<SizeMass;i++) printf("Обнуление summDelta[%d] = %G",i,summDelta[i]);

//Обнуляем отфильтрованные значения массива SizeMassDigit
      for(int i=0;i<SizeMassDigit;i++)
        {
         if(i==0)
           {
            if(summDelta[i]!=0) Digit[i]=Digit[i];
            else Digit[i]=0;
           }
         if(i==1)
           {
            if(summDelta[i-1]!=0 || summDelta[i]!=0) Digit[i]=Digit[i];
            else Digit[i]=0;
           }
         if(i>1 && i<SizeMass)
           {
            if(summDelta[i-2]!=0 || summDelta[i-1]!=0 || summDelta[i]!=0) Digit[i]=Digit[i];
            else Digit[i]=0;
           }
         if(i==SizeMass-1+1) //Предпоследняя ячейка
           {
            if(summDelta[i-1-1]!=0 || summDelta[i-1-2]!=0) Digit[i]=Digit[i];
            else Digit[i]=0;
           }
         if(i==SizeMass-1+2) //Последняя ячейка
           {
            if(summDelta[i-1-2]!=0) Digit[i]=Digit[i];
            else Digit[i]=0;
           }
        }
      for(int i=0;i<SizeMassDigit;i++) printf("Обнуление Digit[%d] = %G",i,Digit[i]);
     }

   SizeMass=ArraySize(summDelta);//Узнаем размер массива
   SizeMassDigit=ArraySize(Digit);//Узнаем размер массива      
   avrMass=0;
   int NOL=0;
   int CalcZero=0;

//Удаление обнуленных данных массива summDelta
   for(int i=0;i<SizeMass;i++)
     {
      if(summDelta[i]!=0)
        {
         ArrayCopy(summDelta,summDelta,i-CalcZero,i,1);
        }
      else CalcZero++;
     }

//Удаление обнуленных данных массива Digit
   CalcZero=0;
   for(int i=0;i<SizeMassDigit;i++)
     {
      if(Digit[i]!=0)
        {
         ArrayCopy(Digit,Digit,i-CalcZero,i,1);
        }
      else CalcZero++;
     }

   for(int i=0;i<SizeMass;i++) printf("До обрезания массива summDelta[%d] = %G",i,summDelta[i]);
   for(int i=0;i<SizeMassDigit;i++) printf("До обрезания массива Digit[%d] = %G",i,Digit[i]);

   SizeMass=ArraySize(summDelta);//Узнаем размер массива
   SizeMassDigit=ArraySize(Digit);//Узнаем размер массива

   Print("N=",N);
   if(N!=0)
     {
      ArrayResize(summDelta,N,0);
      for(int i=0;i<N;i++) printf("summDelta[%d] = %G",i,summDelta[i]);
      ArrayResize(Digit,SizeMassDigit-CalcZero,0);
      for(int i=0;i<SizeMassDigit-CalcZero;i++) printf("Digit[%d] = %G",i,Digit[i]);
     }
   else
     {
      for(int i=0;i<N;i++) printf("summDelta[%d] = %G",i,summDelta[i]);
      for(int i=0;i<SizeMassDigit-CalcZero;i++) printf("Digit[%d] = %G",i,Digit[i]);
      return;
     }

   SizeMass=ArraySize(summDelta);//Узнаем размер массива
   avrMass=iMAOnArray(summDelta,0,SizeMass,0,0,0);
   Print("Среднее значение получившегося числового ряда=",avrMass);

//-Основной алгоритм
//0. Очистим более не нужный массив
         SizeMassDigit=ArraySize(Digit);               //Узнаем размер массива
         ArrayFree  (summDelta);                       //Очищаем массив
         ArrayResize(summDelta,SizeMassDigit-1,0);     //Восстанавливаем нужный размер массива
         SizeMass=ArraySize(summDelta);                //Узнаем размер массива
        
//1. Находим разницу между числами - это как раз их близость друг от друга.
   for(int i=0;i<SizeMass;i++)
     {
      summDelta[i]=(Digit[i+1]-Digit[i]);
     }
   for(int i=0;i<SizeMass;i++) printf("summDelta[%d] = %G",i,summDelta[i]);

avrMass=iMAOnArray(summDelta,0,SizeMass,0,0,0);
   Print("Среднее значение получившегося числового ряда=",avrMass);

//2. Если число меньше среднего значения дельт, получившихся из п.1, то - 1, а если нет - 0.
   for(int i=0;i<SizeMass;i++)
     {
      if (summDelta[i]<avrMass) summDelta[i]=1;
      else summDelta[i]=0;
     }
   for(int i=0;i<SizeMass;i++) printf("summDelta[%d] = %G",i,summDelta[i]);


//3. Если значение из п.2 равно 1, то суммируем значение с предыдущим итогом, если нет - 0.
   for(int i=0;i<SizeMass;i++)
     {
      if (i==0 && summDelta[i]==1) summDelta[i]=1;
      else if (i==0) summDelta[i]=0;
      if (i>0 && summDelta[i]>0) summDelta[i]=summDelta[i-1]+1;
      else if (i>0)  summDelta[i]=0;
     }
   for(int i=0;i<SizeMass;i++) printf("summDelta[%d] = %G",i,summDelta[i]);


//4. Находим максимальное значение из пункта 3.
int Max=ArrayMaximum(summDelta,WHOLE_ARRAY,0);
Print ("Максимальное значение=",Max);

//4.1 Необходимо найти все группы чисел с подозрением на плотность
   for(int i=0;i<SizeMassDigit;i++)
     {
      if (i==0  && summDelta[i]>0) Digit[i]=Digit[i];
      else if (i==0) Digit[i]=0;
      if (i<SizeMass && i>0 && (summDelta[i-1]>0 || summDelta[i]>0)) Digit[i]=Digit[i];
      else if (i<SizeMass && i>0 ) Digit[i]=0;
      if (i==SizeMass && summDelta[i-1]>0) Digit[i]=Digit[i];
      else if (i==SizeMass) Digit[i]=0;
     }    
   for(int i=0;i<SizeMassDigit;i++) printf("Все группы чисел с подозрением на плотность Digit[%d] = %G",i,Digit[i]);


//5. Определяем диапазон - находим значение из пункта 4 и ищем вверх из пункта 3 число с нулевым значением, потом увеличиваем найденное число на единицу.
//Таким образом мы получаем диапазон чисел, плотность которых наибольшая по отношению к другим.
  }
//+------------------------------------------------------------------+
 
-Aleks-:

Well, it's obvious now that you are unable to back up your fantasies with action.

Good luck finding another place to assert yourself!

Mine's not here.
 
Renat Akhtyamov:
Mine's not here.

I check my fantasies - I work on them - I check them, but you don't.

 

Tried this number series:

40
56
31
42
46
51
545
13
65
71
78
81
10
15
190
21
223
232
250
260

I got the following numbers (although there's another zero in there - I'll have to figure out why):

10
13
15
21
40
42
46
51
56
78
81

Graphically it looks like this:

The graph shows that dense groups of numbers are found (Row 2).

Looks not bad, but without objective criticism and verification can not - I ask willing to find flaws in the algorithm. Interested in alternative solutions, but with a provable basis.

Reason: