Rompendo o apartamento da manhã - quais pares? - página 22

 

Dserg, você poderia fazer outra versão do indicador http://Dserg-LinRegressionBreakout_v1.1.mq4 comhora de início e de fim do canal em vez deNlin.

Seria muito apreciado.
 
gince:

Dserg, você poderia fazer outra versão do indicador http://Dserg-LinRegressionBreakout_v1.1.mq4 comhora de início e de fim do canal em vez deNlin.

Seria muito apreciado.

Seria melhor se um novo canal não fosse necessariamente formado após o final do canal anterior. Uma vez que uma nova tendência muitas vezes começa antes que o canal anterior esteja terminado. Ou seja, deveria haver a possibilidade de formar canais com sobreposição, e para melhor visualização da imagem, os canais vizinhos deveriam ser de cores diferentes (2 cores são suficientes).

 

Eu mesmo o experimentei, mas não funcionou. Talvez alguém possa corrigi-lo.

//+------------------------------------------------------------------+
//|                                                                  |
//|       Èíäèêàòîð äëÿ àâòîìàòè÷åñêîãî ïîñòðîåíèÿ ñóæåíèÿ           |
//|       êàíàëîâ ëèíåéíîé ðåãðåññèè                                 |
//|                               https://www.mql5.com/ru/users/dserg |
//+------------------------------------------------------------------+
#property  copyright "Dserg, 2010"
#property  link      "https://www.mql5.com/ru/users/dserg"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 8
#property indicator_color1 DeepSkyBlue
#property indicator_color2 DeepSkyBlue
#property indicator_color3 FireBrick
#property indicator_color4 DeepSkyBlue
#property indicator_color5 DeepSkyBlue
#property indicator_color6 Yellow
#property indicator_color7 HotPink
#property indicator_color8 LawnGreen 

//---- buffers
double B0[];
double B1[];
double Stop[];
double B3[];
double B4[];
double Up[];
double Dn[];
double Target[];

extern string S1="Ìèí. äëèíà êàíàëà ëèíåéíîé ðåãðåññèè";
extern int Nlin;
extern int start = 20;
extern int  stop = 7;
extern string S2="Ìàêñ. âûñîòà êàíàëà â ïóíêòàõ";
extern int r0=150;
extern string S3="Öåëü ïðè ïðîáîå îòí. øèðèíû êàíàëà";
extern double t0=2.618;
extern string S4="Èñïîëüçîâàòü äëÿ ðàñ÷¸òà Close,\n åñëè false - High/Low";
extern bool useClose=true;
extern string S5="Êîëè÷åñòâî áàðîâ äëÿ ðàññ÷¸òà";
extern int Nbars=5000;

bool isChannel;
datetime chEnd;
double a0;
double b0;
double range0;
datetime PrevTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 3additional buffers are used for counting.
   
//---- drawing settings

   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0, B0);      
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(1, B1);      
   SetIndexStyle(2,DRAW_ARROW,0,2);
   SetIndexBuffer(2, Stop);      
   SetIndexStyle(3,DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(3, B3);      
   SetIndexStyle(4,DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(4, B4);      

   SetIndexStyle(5,DRAW_ARROW,0,1);
   SetIndexBuffer(5, Up);      
   SetIndexArrow(5, 233);        
   SetIndexStyle(6,DRAW_ARROW,0,1);
   SetIndexBuffer(6, Dn);      
   SetIndexArrow(6, 234);        
   SetIndexStyle(7,DRAW_ARROW,0,1);
   SetIndexBuffer(7, Target);      
   SetIndexArrow(7, 231);        

   SetIndexEmptyValue(0,0.0);   
   SetIndexEmptyValue(1,0.0);   
   SetIndexEmptyValue(2,0.0);   
   SetIndexEmptyValue(3,0.0);   
   SetIndexEmptyValue(4,0.0);   
   SetIndexEmptyValue(5,0.0);   
   SetIndexEmptyValue(6,0.0);   
   SetIndexEmptyValue(7,0.0);   

   SetIndexLabel(0,"Channel Low");
   SetIndexLabel(1,"Channel High");
   SetIndexLabel(2,"Stop/Reverse");
   SetIndexLabel(3,"Channel Low Extended");
   SetIndexLabel(4,"Channel High Extended");
   SetIndexLabel(5,"BUY Signal");
   SetIndexLabel(6,"SELL Signal");
   SetIndexLabel(7,"Target");

   isChannel=false;
   
   return(0);
  } 

int deinit()
  {
  } 
//---------------------------------------------------------------------------------------
int start()

  {
  Nlin = (24 - (start-stop))*60/Period(); 
        Comment("Nlin = "+ Nlin);
 //if (iTime(NULL,PERIOD_D1,0)!=PrevTime)  return(0);
 //PrevTime = iTime(NULL,PERIOD_D1,0);
 
     if(Bars-IndicatorCounted()==0) return(0);
     // int loopbegin = Bars - IndicatorCounted()+20*Nlin;
      int loopbegin = Nbars;
 
      int i,j;
      double a,b,c,
             sumy=0.0,
             sumx=0.0,
             sumxy=0.0,
             sumx2=0.0,
             h=0.0,l=0.0,
             range = 0.0;   
      isChannel=false;
      for(i = loopbegin; i >= 0; i--) {
         B0[i]=0;
         B1[i]=0;
         B3[i]=0;
         B4[i]=0;
         Up[i]=0;
         Dn[i]=0;
         Stop[i]=0;
         Target[i]=0;
      }
      
      for(i = loopbegin; i >= 0; i--) {
         
         
         //ó íàñ óæå åñòü êàíàë, æä¸ì, ïîêà åãî ïðîáü¸ò
         if (isChannel) {
            //double up0=a0*(i-chEnd)+b0+range0;
            //double dn0=a0*(i-chEnd)+b0-range0;
            double up0=a0*i+b0+range0;
            double dn0=a0*i+b0-range0;
            B3[i]=up0;
            B4[i]=dn0;
            //ïðîâåðÿåì ïðîáèòèå
            //ââåðõ
            if (Open[i]>up0) {
               Up[i]=up0;
               Stop[i]=dn0;
               Target[i]=up0+(up0-dn0)*(t0-1);
               isChannel=false;
               //continue;
            }
            //âíèç
            if (Open[i]<dn0) {
               Dn[i]=dn0;
               Stop[i]=up0;
               Target[i]=dn0-(up0-dn0)*(t0-1);
               isChannel=false;
               //continue;
            }
            continue;
         }            

         bool flag=false;
         for (j=0;j<Nlin+1;j++) {
            if (B3[i+j]>0.0&&!isChannel) {
               flag=true;
            }
         }
         if (flag) continue;
         
         
         a=0.0;b=0.0;c=0.0;
         sumx=0.0;sumy=0.0;
         sumxy=0.0;sumx2=0.0;
         h=0.0;l=0.0;

         //ñ÷èòàåì êàíàë ëèíåéíîé ðåãðåññèè îò i+Nlin äî i 
         if(StrToTime(stop) != Hour())return(0);
         for(j=0; j<Nlin; j++)
         {
            sumy+=Close[i+j];
            sumxy+=Close[i+j]*(i+j);
            sumx+=(i+j);
            sumx2+=(i+j)*(i+j);
         }
         c=sumx2*Nlin-sumx*sumx;
         if(c==0.0) {
            Alert("Error in linear regression!");
            return(-1);
         }
         a=(sumxy*Nlin-sumx*sumy)/c;
         b=(sumy-sumx*a)/Nlin;
         
         //îïðåäåëÿåì ãðàíèöû êàíàëà
         for(j=0;j<Nlin;j++)
         {
           double LR=a*(i+j)+b;
           if (useClose) {
             if(Close[j+i]-LR > h) h = Close[i+j]-LR;
             if(LR - Close[i+j]> l) l = LR - Close[i+j];
           } else {
             if(High[j+i]-LR > h) h = High[i+j]-LR;
             if(LR - Low[i+j]> l) l = LR - Low[i+j];
           }           
         }  
         range = MathMax(l,h);
         
         //ïðîâåðêà øèðèíû êàíàëà
         //if (range<r0*Point) {
            //åñòü êàíàë, ñîõðàíÿåì
            isChannel=true;
            a0=a;
            b0=b;
            chEnd=iTime(NULL,0,i);
            range0=range;
            
            for (j=0;j<Nlin;j++) {
               B3[i+j]=a*(i+j)+b+range;
               B4[i+j]=a*(i+j)+b-range;
               B0[i+j]=a*(i+j)+b+range;
               B1[i+j]=a*(i+j)+b-range;
            }
         //}
            

         
      }
      return(0);
  }
//+------------------------------------------------------------------+



            
            
 
Você tem por definição B0[k]=B3[k]; B1[k]=B4[k]; k=qualquer um
 
tara:
У Вас по определению получается B0[k]=B3[k]; B1[k]=B4[k]; k=любое

tara
:

Por definição, você recebe B0[k]=B3[k]; B1[k]=B4[k]; k=em qualquer lugar


| Este é o autor de Dserg. Mas deveria ser assim. B0[k]; B1[k] são linhas de canal STYLE_SOLID, outras linhas são extensões das duas primeiras linhas STYLE_DOT

O que eu tentei mudar no código está marcado em negrito. No início, calculei o número de barras, ou seja, o comprimento do canal. Depois, o canal é desenhado uma vez por dia para verificar se há um novo dia. Depois acrescentei uma verificação de tempo. Se o tempo do canal tiver expirado, então devemos lê-lo e desenhá-lo.

mas não funciona.

 
Ainda não li o fio. Você já o viu aqui ?
 
Gostaria de olhar para isso de um ângulo diferente, mas a pesquisa precisa de um indicador. Não posso escrevê-lo eu mesmo e ninguém corrigiu minhas fuck-ups. Estou desenhando os canais à mão, mas estou farto da barra a partir da qual se pode desenhar o canal. Na história de dez kalals não pode resolver nada
 

O tema é interessante. Há um desejo de ir mais fundo...

Há também uma descrição do TS aqui.

Vou postar o que encontrar aqui e não no tópico "avaria plana matinal".

 

Encontrei o tópico completamente por acidente na assinatura do meu perfil.

Quem está cavando nessa direção?

IMHO - é hora de cavar mais fundo...

 
Roman.:

Encontrei o tópico completamente por acidente na assinatura do meu perfil.

Quem está cavando nessa direção?

IMHO - é hora de cavar mais fundo...

Na tendência é super... Em uma direção plana eu nunca entro em um colapso...
Razão: