Индикаторы: Divination _MA

 

Divination _MA:

Поклонникам МА.

Author: Evgeniy

 
интересно, жаль нет результатов с тестера?
 
MilordFX:
интересно, жаль нет результатов с тестера?


Индикатор не предназначен для торговли, по этому не представляю, как его протестировать .

За оценку, спасибо !

 
+
 

vorese: .... не представляю, как его протестировать ....

Предлагаю оформить скриптом с выводом результата в Excel. При этом можно вывести результаты для каждой свечи и в сводной таблице посмотреть наиболее частые. Потом с помощью индикатора на графике.

 
pa0905:

vorese: .... не представляю, как его протестировать ....

Предлагаю оформить скриптом с выводом результата в Excel. При этом можно вывести результаты для каждой свечи и в сводной таблице посмотреть наиболее частые. Потом с помощью индикатора на графике.


Доработал индикатор, теперь можно видеть результат сравнения сразу нескольких баров . В качестве фильтра направления движения цены использован ZigZag.

Индикатор получился тяжёлый, по этому не советую ставить сразу большое количество баров для расчета .

Столбики гистограммы белого и желтого цветов - вершины ZigZag .

Код индикатора на модерации, пока выкладываю так :

#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Lime
#property  indicator_color2  Snow
#property  indicator_color3  Red
#property  indicator_color4  Yellow
extern string s1="-----Период МА-----";
extern int Period_MA1=5;
extern int Period_MA2=15;
extern int Period_MA3=45;
extern string s2="-----Метод расчета МА-----";
extern int metod_MA1=1;
extern int metod_MA2=1;
extern int metod_MA3=1;
extern string s3="-----Ценовая константа МА-----";
extern int price_MA1=5;
extern int price_MA2=5;
extern int price_MA3=5;
extern string s4="===========================================";
extern string s5="---кол-во баров истории-----";
extern int History_bars=1000;
extern string s6="---кол-во баров гистограммы-----";
extern int Histogram_bar = 100;
extern string s7="ценовая константа бара";
extern int price_const=5;
extern string s8="допуст. отклонение цены %-----";
extern double deviation_perc=40;
extern string s9="===========================================";
extern string s10="комментарии";
extern bool active_Comment=true;
//+--------------------------------------------------------------------
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
double     ExtBuffer3[];
 double mas_bar[];
 double ZigZag[];
 double ZZ_H[];
 double ZZ_L[];
 int zz_h,zz_l,zz_hh,zz_ll;
 bool tick=false;
 datetime time_bar=0;
 double bar; 
 int count_bar;
 int history;
 //===================================================================
int init()
  {      
 //-------------------------------------------------------------------
       IndicatorBuffers(8);
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
   SetIndexBuffer(3,ExtBuffer3);
   SetIndexBuffer(4,mas_bar); 
   SetIndexBuffer(5,ZigZag);  
   SetIndexBuffer(6,ZZ_H);  
   SetIndexBuffer(7,ZZ_L); 
   SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, 2);
   SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, 4);
   SetIndexStyle(2,DRAW_HISTOGRAM, EMPTY, 2);   
   SetIndexStyle(3,DRAW_HISTOGRAM, EMPTY, 4);  
   SetIndexStyle(4,DRAW_NONE);
   SetIndexStyle(5,DRAW_NONE);
   SetIndexStyle(6,DRAW_NONE);
   SetIndexStyle(7,DRAW_NONE);  
   if(History_bars>=Bars)history=Bars;
   else
      history=History_bars; 
   return(0);
  }
//====================================================================
int deinit()
  {
            
   return(0);
  }                       
//====================================================================
int start()
  { 
  int h,l,w,bar_num,shift;
  int tilt1,tilt2,tilt3,tilt1i,tilt2i,tilt3i;                           // наклон МА
  int sign1,sign2,sign3,sign1i,sign2i,sign3i;                           //знак цены
  int position1,position2,position3,position1i,position2i,position3i;   //распол.МА между собой
  double pips1,pips2,pips3,pips1i,pips2i,pips3i;      //разность между ценой МА и ценой бара 
  double ma1,ma2,ma3,ma11,ma22,ma33,ma1i,ma2i,ma3i,ma11i,ma22i,ma33i;   //цена МА
  int count_zz;
  double single_zz,single_h,single_l;  
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // int    limit;
  // int    counted_bars=IndicatorCounted();
  // if(counted_bars>0) counted_bars--;
  // limit=Bars-counted_bars;
//----------------------------------------------------------------------- 
   for(int i=0; i<Bars-1; i++)
   {
     single_zz=iCustom(NULL,0,"ZigZag",12,5,3,0,i);
     single_h=iCustom(NULL,0,"ZigZag",12,5,3,1,i);
     single_l=iCustom(NULL,0,"ZigZag",12,5,3,2,i);
 
     if( single_h>0 && single_zz>0) { ZZ_H[count_zz]=i;ZZ_L[count_zz]=0; count_zz++;}
     if( single_l>0 && single_zz>0) { ZZ_L[count_zz]=i;ZZ_H[count_zz]=0; count_zz++;} 
     }  
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
     if(time_bar!=Time[0]) { time_bar=Time[0];tick=true; }
       else
           tick=false;
      if(tick)
      {      
                   for(shift=1;shift<Histogram_bar;shift++)
       {                  
                  count_bar=0;           
         ma1=iMA(NULL,0,Period_MA1,0,metod_MA1,price_MA1,shift);
         ma2=iMA(NULL,0,Period_MA2,0,metod_MA2,price_MA2,shift);
         ma3=iMA(NULL,0,Period_MA3,0,metod_MA3,price_MA3,shift);
        
         ma11=iMA(NULL,0,Period_MA1,0,metod_MA1,price_MA1,shift+1);
         ma22=iMA(NULL,0,Period_MA2,0,metod_MA2,price_MA2,shift+1);
         ma33=iMA(NULL,0,Period_MA3,0,metod_MA3,price_MA3,shift+1);
//--------------------------------------------------------------------     
         pips1=ma1-f_Price_bar( price_const,shift);
         pips2=ma2-f_Price_bar( price_const,shift);
         pips3=ma3-f_Price_bar( price_const,shift); 
//--------------------------------------------------------------------         
         sign1=f_Comparison(pips1,0);
         sign2=f_Comparison(pips2,0);                      
         sign3=f_Comparison(pips3,0);
//--------------------------------------------------------------------        
         position1=f_Comparison(ma1,ma2);
         position2=f_Comparison(ma1,ma3);
         position3=f_Comparison(ma2,ma3);
//--------------------------------------------------------------------              
         tilt1=f_Comparison(ma1,ma11);
         tilt2=f_Comparison(ma2,ma22);
         tilt3=f_Comparison(ma3,ma33);         
//====================================================================   
//--------------------------------------------------------------------              
      for( w=1;w<history;w++)    
      {                            
         ma1i=iMA(NULL,0,Period_MA1,0,metod_MA1,price_MA1,w);
         ma2i=iMA(NULL,0,Period_MA2,0,metod_MA2,price_MA2,w);
         ma3i=iMA(NULL,0,Period_MA3,0,metod_MA3,price_MA3,w);
        
         ma11i=iMA(NULL,0,Period_MA1,0,metod_MA1,price_MA1,w+1);
         ma22i=iMA(NULL,0,Period_MA2,0,metod_MA2,price_MA2,w+1);
         ma33i=iMA(NULL,0,Period_MA3,0,metod_MA3,price_MA3,w+1); 
//--------------------------------------------------------------------                 
         pips1i=ma1i-f_Price_bar( price_const,w);
         pips2i=ma2i-f_Price_bar( price_const,w);
         pips3i=ma3i-f_Price_bar( price_const,w); 
//--------------------------------------------------------------------      
         sign1i=f_Comparison(pips1i,0);
         sign2i=f_Comparison(pips2i,0);                      
         sign3i=f_Comparison(pips3i,0);
//--------------------------------------------------------------------
         position1i=f_Comparison(ma1i,ma2i);
         position2i=f_Comparison(ma1i,ma3i);
         position3i=f_Comparison(ma2i,ma3i);
//--------------------------------------------------------------------         
         tilt1i=f_Comparison(ma1i,ma11i);
         tilt2i=f_Comparison(ma2i,ma22i);
         tilt3i=f_Comparison(ma3i,ma33i);   
//-------------------------------------------------------------------- 
           if ( position1==position1i && position2==position2i && position3==position3i )                     
          { if ( tilt1==tilt1i && tilt2==tilt2i && tilt3==tilt3i ) 
           { if ( sign1==sign1i && sign2==sign2i && sign3==sign3i )         
            { if ( MathAbs(pips1)<=MathAbs(pips1i)+MathAbs(pips1i)*deviation_perc/100 
                && MathAbs(pips1)>=MathAbs(pips1i)-MathAbs(pips1i)*deviation_perc/100
                && MathAbs(pips2)<=MathAbs(pips2i)+MathAbs(pips2i)*deviation_perc/100
                && MathAbs(pips2)>=MathAbs(pips2i)-MathAbs(pips2i)*deviation_perc/100
                && MathAbs(pips3)<=MathAbs(pips3i)+MathAbs(pips3i)*deviation_perc/100
                && MathAbs(pips3)>=MathAbs(pips3i)-MathAbs(pips3i)*deviation_perc/100 )                                       
         { if( shift!=w)
       { mas_bar[count_bar]= w; 
                   count_bar++; } 
             } } } }                                                                    
       }  //конец цикла w    
 //====================================================================  
           zz_h=0;
           zz_l=0;
           zz_hh=0;
           zz_ll=0; 
       for(h=0;h<count_bar;h++)
       {   bar=mas_bar[h];
          for(l=0;l<count_zz;l++)
         {     
         if(bar>ZZ_H[l] && bar<ZZ_L[l+1] && ZZ_L[l]==0 && ZZ_H[l]!=0)
         { zz_h++;}
         if(bar>ZZ_L[l] && bar<ZZ_H[l+1] && ZZ_H[l]==0 && ZZ_L[l]!=0)
         { zz_l++;} 
         if(bar==ZZ_H[l] && bar>0)
         {zz_hh++;}
         if(bar==ZZ_L[l] && bar>0)
         {zz_ll++;} 
         } 
      } 
      ExtBuffer0[shift]=zz_h;
       ExtBuffer2[shift]=(-zz_l);
        ExtBuffer1[shift]=zz_hh;
         ExtBuffer3[shift]=(-zz_ll);
      }   //конец цикла shift  
      }//tick            
  //========================================================================      
   if(active_Comment) 
   Comment(" Гистограмма: баров ",Histogram_bar,
  "\n"," баров в истории   ",Bars, 
  "\n"," обработано баров  ",history );
   return(0);
  }
//+------------------------------------------------------------------+
    double f_Price_bar(int constant,int bar)//  цена бара
      {
         double price;
      switch(constant)      
       { case 0:price=Close[bar]; break;  
          case 1:price=Open[bar]; break;
           case 2:price=High[bar]; break;
            case 3:price=Low[bar]; break;
             case 4:price=(High[bar]+Low[bar])/2; break;
              case 5:price=(Close[bar]+High[bar]+Low[bar])/3; break;
               case 6:price=(Close[bar]+Close[bar]+High[bar]+Low[bar])/4; break;
                case 7:price=(Open[bar]+Close[bar])/2; break;    }
      return(NormalizeDouble(price,Digits));
         }
//====================================================================
int f_Comparison (double variable_1,double variable_2)
     {
       int results;
       if(variable_1>variable_2)results=1;
       else {
         if(variable_1<variable_2)results=(-1);
       else 
           results=0;  } 
         return(results);
         }                              
//====================================================================    
Причина обращения: