Ajuda na codificação - página 672

 
mladen:

NWFstudent

Por que você não usa o código fonte original para começar (o indicador bb stop sempre foi gratuito, não há necessidade de usar a versão descompilada, e é muito mais fácil trabalhar com o código original)

Obrigado por seu conselho, Sr. mladen.

Onde posso encontrar o código original?

EDIT: Acho que encontrei um código muito mais limpo e legível, graças a milhares de vezes.

Isto é certo?

//+------------------------------------------------------------------+
//|                                               BBands_Stop_v1.mq4 |
//|                           Copyright © 2006, TrendLaboratory Ltd. |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                       E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"
//----
#property indicator_chart_window
#property indicator_buffers 6
#property  indicator_color1 Chartreuse
#property  indicator_color2 Orange
#property  indicator_color3 Chartreuse
#property  indicator_color4 Orange
#property  indicator_color5 Chartreuse
#property  indicator_color6 Orange
//---- input parameters
extern int    Length=20;      // Bollinger Bands Period
extern int    Deviation=2;    // Deviation
extern double MoneyRisk=1.00; // Offset Factor
extern int    Signal=1;       // Display signals mode: 1-Signals & Stops; 0-only Stops; 2-only Signals;
extern int    Line=1;         // Display line mode: 0-no,1-yes  
extern int    Nbars=1000;
//---- indicator buffers
double UpTrendBuffer[];
double DownTrendBuffer[];
double UpTrendSignal[];
double DownTrendSignal[];
double UpTrendLine[];
double DownTrendLine[];
double smax[],smin[],bsmax[],bsmin[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  int init()
  {
   string short_name;
//---- indicator line
   SetIndexBuffer(0,UpTrendBuffer);
   SetIndexBuffer(1,DownTrendBuffer);
   SetIndexBuffer(2,UpTrendSignal);
   SetIndexBuffer(3,DownTrendSignal);
   SetIndexBuffer(4,UpTrendLine);
   SetIndexBuffer(5,DownTrendLine);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   SetIndexArrow(2,108);
   SetIndexArrow(3,108);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   short_name="BBands Stop("+Length+","+Deviation+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"UpTrend Stop");
   SetIndexLabel(1,"DownTrend Stop");
   SetIndexLabel(2,"UpTrend Signal");
   SetIndexLabel(3,"DownTrend Signal");
   SetIndexLabel(4,"UpTrend Line");
   SetIndexLabel(5,"DownTrend Line");
//----
   SetIndexDrawBegin(0,Length);
   SetIndexDrawBegin(1,Length);
   SetIndexDrawBegin(2,Length);
   SetIndexDrawBegin(3,Length);
   SetIndexDrawBegin(4,Length);
   SetIndexDrawBegin(5,Length);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Bollinger Bands_Stop_v1                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift,trend;
//----
   /*for(shift=Nbars;shift>=0;shift--)
     {
      UpTrendBuffer[shift]=0;
      DownTrendBuffer[shift]=0;
      UpTrendSignal[shift]=0;
      DownTrendSignal[shift]=0;
      UpTrendLine[shift]=EMPTY_VALUE;
      DownTrendLine[shift]=EMPTY_VALUE;
     }
*/     
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0)  return(-1);
   if(counted_bars > 0)   counted_bars--;
   int limit = Bars - counted_bars;
   if(counted_bars==0) limit-=1+1;
   
   int xsize=ArraySize(UpTrendBuffer);  
   ArrayResize(smax,xsize);
   ArrayResize(smin,xsize);
   ArrayResize(bsmax,xsize);
   ArrayResize(bsmin,xsize);
   
   for(shift=limit;shift>=0;shift--)
     {
      smax[shift]=iBands(NULL,0,Length,Deviation,0,PRICE_CLOSE,MODE_UPPER,shift);
      smin[shift]=iBands(NULL,0,Length,Deviation,0,PRICE_CLOSE,MODE_LOWER,shift);
//----
      if (Close[shift]>smax[shift+1]) trend=1;
      if (Close[shift]<smin[shift+1]) trend=-1;
      if(trend>0 && smin[shift]<smin[shift+1]) smin[shift]=smin[shift+1];
      if(trend<0 && smax[shift]>smax[shift+1]) smax[shift]=smax[shift+1];
//----
      bsmax[shift]=smax[shift]+0.5*(MoneyRisk-1)*(smax[shift]-smin[shift]);
      bsmin[shift]=smin[shift]-0.5*(MoneyRisk-1)*(smax[shift]-smin[shift]);
//----
      if(trend>0 && bsmin[shift]<bsmin[shift+1]) bsmin[shift]=bsmin[shift+1];
      if(trend<0 && bsmax[shift]>bsmax[shift+1]) bsmax[shift]=bsmax[shift+1];
      if (trend>0)
        {
         if (Signal>0 && UpTrendBuffer[shift+1]==-1.0)
           {
            UpTrendSignal[shift]=bsmin[shift];
            UpTrendBuffer[shift]=bsmin[shift];
            if(Line>0) UpTrendLine[shift]=bsmin[shift];
           }
         else
           {
            UpTrendBuffer[shift]=bsmin[shift];
            if(Line>0) UpTrendLine[shift]=bsmin[shift];
            UpTrendSignal[shift]=-1;
           }
         if (Signal==2) UpTrendBuffer[shift]=0;
         DownTrendSignal[shift]=-1;
         DownTrendBuffer[shift]=-1.0;
         DownTrendLine[shift]=EMPTY_VALUE;
        }
      if (trend<0)
        {
         if (Signal>0 && DownTrendBuffer[shift+1]==-1.0)
           {
            DownTrendSignal[shift]=bsmax[shift];
            DownTrendBuffer[shift]=bsmax[shift];
            if(Line>0) DownTrendLine[shift]=bsmax[shift];
           }
         else
           {
            DownTrendBuffer[shift]=bsmax[shift];
            if(Line>0)DownTrendLine[shift]=bsmax[shift];
            DownTrendSignal[shift]=-1;
           }
         if (Signal==2) DownTrendBuffer[shift]=0;
         UpTrendSignal[shift]=-1;
         UpTrendBuffer[shift]=-1.0;
         UpTrendLine[shift]=EMPTY_VALUE;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
 
NWFstudent:

Obrigado por seu conselho, Sr. mladen.

Onde posso encontrar o código original?

EDIT: Acho que encontrei um código muito mais limpo e legível, graças a milhares de vezes.

Isto é certo?

Sim, é esse mesmo :)
 
NWFstudent:

Obrigado por seu conselho, Sr. mladen.

Onde posso encontrar o código original?

EDIT: Acho que encontrei um código muito mais limpo e legível, graças a milhares de vezes.

Isto é certo?

NWFstudent

Acho que esta da barra limitada MLADENs e esta das versões da linha MRTOOLs são mais recentes e com formato mq4.

com respeito a


 

Mladen

Estou tentando fazer com que o TMA mtf funcione no meu EA. Tenho o "tma centrado" cruzando os 200ma para trabalhar, mas o 1 & 1 do mtf parece ser mais cedo por alguma razão & oportuno, veja meu gráfico.

Você pode verificar minha EA. Neste momento, ele está configurado para comercializar no "TMA mtf", o buffer de tendência #3. Ele compila e roda no testador, mas sem trocas e sem erros. A única mudança que fiz no mtf TMA foi adicionar o SetIndexLabels. Se eu carrego ambos os indicadores demas em um gráfico, eles se espelham um ao outro.

Agradeço qualquer ajuda.

Ray

 
traderduke:

Mladen

Estou tentando fazer com que o TMA mtf funcione em minha EA. Consegui que o "tmacentered" cruzasse os 200ma para trabalhar, mas o 1 & 1 do mtf parece ser mais cedo por alguma razão & oportuno, veja meu gráfico.

Você pode verificar minha EA. Neste momento, ele está configurado para negociar no "TMAmtf", o buffer de tendência nº 3. Ele compila e roda no testador, mas sem trocas e sem erros. A única mudança que fiz no TMA mtf foi adicionar o SetIndexLabels. Se eu carregar os dois indicadores demas em um gráfico, eles se espelham um ao outro.

Agradeço qualquer ajuda.

Ray

Isso é um problema com o recálculo/repintura de indicadores. Não é possível utilizá-los para sinais. Dê uma olhada na forma como funciona em tempo de execução, e então você verá porque não pode funcionar usando essa lógica no EA
 
dotmund:
encontrei este indicador neste site e achei útil que pls você pode me ajudar a fazer uma EA dele e fazer com que ele seja comercializado imediatamente quando a flecha aparecer e fechá-lo no fechamento da próxima vela, o que significa que ele irá comercializar apenas duas velas e deve fechar se a flecha oposta aparecer. pls
pls me ajudem com isto .
 

Olá juntos.

Alguém pode me ajudar a adicionar neste Channel-Indikator, como posso esconder os Canais superiores?!

Eu só preciso de M1, M5, M15 e não entendo esse código....


 //+------------------------------------------------------------------+
//|                                                    !channels.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Nikolay Semko SemkoNV@bk.ru"
#property link        "http://www.7ko.org" // in the development of

// praise and scold at: SemkoNV@bk.ru

#property   indicator_chart_window
#property   indicator_buffers 1


#property   indicator_width1   1
#property   indicator_minimum 0
//---- indicator parameters

extern int Start= 0 ;
extern int BarAnaliz= 400 ;
extern double k_shirina= 4 ;
extern int tochnost = 50 ;
extern double filtr = 0.55 ;
extern double MinShirina = 0 ;
extern double MaxShirina = 10000 ;
extern bool luch= true ;
extern bool maxmin= true ;
extern bool color_fill= true ;

//---- indicator buffers

double      Canals[];
double      Shir[];
double      Vertikal[];

double      Shirina[];
double      ShirinaU[];
double      ShirinaD[];
double      CanalR[];
double      CanalL[];
double      Kanals[ 20 ][ 9 ];

int preBars= 0 ;
int p[ 9 ]={ 43200 , 10080 , 1440 , 240 , 60 , 30 , 15 , 5 , 1 };
int FinishL;
int tick= 0 ;
int bar= 0 ;
int b= 0 ;
//datetime x1,x2;
double sumPlus= 0 ;
double sumMinus= 0 ;
double yOptR,yOptL;
int prexL= 0 ;
int prexR= 0 ;
double ma= 0 ;
int   prevxR=- 5 ;
int   prevp= 0 ;
int prevper=- 5 ;
double sum1= 0 ;
double sum2= 0 ;
double curdeltaMax=- 10000 ;
double curdeltaMin= 10000 ;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void deinit()
  {
   Comment ( "" );
   for ( int i= 0 ;i< 20 ;i++)
     {
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 ));
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " UP" );
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " DOWN" );
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " TRIUP" );
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " TRIDown" );
       ObjectDelete ( "Vertical_9_" + DoubleToStr (i, 0 ));
     }
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   IndicatorDigits ( Digits + 1 );
//---- indicator buffers mapping

   LoadHist();
//---- indicator buffers mapping

//SetIndexBuffer(0,Canals);
//   IndicatorDigits(20);

//---- initialization done
   return ( 0 );
  }
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

int start()
  {
//LoadHist();
   RefreshRates ();
//return(0);
   if (preBars == Bars ) return ( 0 );
   preBars= Bars ;

   int size= Bars ;
   ArrayResize (Shirina,size);
   ArrayResize (ShirinaU,size);
   ArrayResize (ShirinaD,size);
   ArrayResize (CanalR,size);
   ArrayResize (CanalL,size);

   ArrayResize (Canals,size);
   ArrayResize (Shir,size);
   ArrayResize (Vertikal,size);

/*double     Shirina[2000];
double     ShirinaU[2000];
double     ShirinaD[2000];
double     CanalR[2000];
double     CanalL[2000];*/

   int j=AllCanals();
   Canals[ 0 ]=j;

   if (j> 0 )
     {
       for ( int i= 0 ; i<j; i++)
        {
         Canals[ 7 *i+ 1 ] = Kanals[i][ 0 ];
         Canals[ 7 *i+ 2 ] = Kanals[i][ 1 ];
         Canals[ 7 *i+ 3 ] = Kanals[i][ 2 ];
         Canals[ 7 *i+ 4 ] = Kanals[i][ 3 ];
         Canals[ 7 *i+ 5 ] = Kanals[i][ 4 ];
         Canals[ 7 *i+ 6 ] = Kanals[i][ 5 ]/ Point ;
         Canals[ 7 *i+ 7 ] = Kanals[i][ 6 ];
         Canals[ 7 *i+ 8 ] = Kanals[i][ 7 ];
         Canals[ 7 *i+ 9 ] = Kanals[i][ 8 ];
        }
      BildCanals(j);
     }
   return ( 0 );
  }
//+------------------------------------------------------------------+
///////////////////////////// Functions //////////////////////////////
//+------------------------------------------------------------------+

int BildCanals( int j)
  {
   string name;
   datetime x1,x2;
   double y1,y2;
//int  color_i[]={Red,Tomato,Yellow,LawnGreen,Green,Aqua,MediumBlue,BlueViolet,FireBrick,BurlyWood,DeepPink,SeaGreen};
   int   color_i[]={ C'200,0,0' , C'200,100,0' , C'160,160,0' , C'100,200,0' , C'0,200,0' , C'0,200,100' , C'0,180,180' , C'0,60,120' , C'0,0,200' , C'100,0,200' , C'160,0,160' , C'160,80,120' };
   int color_i2[]={ C'80,0,0' , C'80,40,0' ,   C'60,60,0' ,   C'40,80,0' ,   C'0,60,0' , C'0,70,50' ,   C'0,50,50' ,   C'0,20,40' , C'0,0,80' , C'40,0,80' ,   C'50,0,60' ,   C'60,20,50' };
   for ( int i=j;i< 20 ;i++)
     {
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 ));
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " UP" );
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " DOWN" );
       ObjectDelete ( "Vertical_9_" + DoubleToStr (i, 0 ));
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " TRIUP" );
       ObjectDelete ( "LineCanal9_" + DoubleToStr (i, 0 )+ " TRIDown" );
      Kanals[i][ 2 ]= 0 ;
      Kanals[i][ 1 ]= 0 ;
      Kanals[i][ 0 ]= 0 ;
     }

   string comm= "Number of channels = " ;
   comm=comm+j;
   for (i= 0 ; i<j; i++)
     { comm=comm+ "\n" + "Channel ¹ " + DoubleToStr ((i+ 1 ), 0 )+ " : width - " + DoubleToStr (Kanals[i][ 0 ], 0 )+ ", channel length -  " + DoubleToStr (Kanals[i][ 6 ], 0 )+ " bars on period " + DoubleToStr (Kanals[i][ 2 ], 0 );}
   Comment (comm);

   for (i= 0 ; i<j; i++)
     {
      x1 = iTime ( NULL , 0 ,Start);
      y1 = Kanals[i][ 3 ];
       if ( iTime ( NULL , 0 ,( Bars - 1 ))<= iTime ( NULL ,Kanals[i][ 2 ],Kanals[i][ 1 ]))
        {
         x2 = iTime ( NULL ,Kanals[i][ 2 ],Kanals[i][ 1 ]);
         y2 = Kanals[i][ 4 ];
        }
       else
        {
         x2= iTime ( NULL , 0 ,( Bars - 1 ));
         if (Kanals[i][ 6 ]!= 0 ) y2=y1-(( iBarShift ( NULL ,Kanals[i][ 2 ],x2, FALSE )- iBarShift ( NULL ,Kanals[i][ 2 ],x1, FALSE ))/Kanals[i][ 6 ])*(y1-Kanals[i][ 4 ]);
        }

      name= "LineCanal9_" + DoubleToStr (i, 0 );
       if ( ObjectFind (name)==- 1 )
        {
         if (! ObjectCreate (name, OBJ_TREND , 0 ,x2,y2,x1,y1)) Comment ( "Error 0 = " , GetLastError ());
         ObjectSet (name, OBJPROP_RAY , FALSE );

         color col1=color_i[ 0 ];
         if ((i>= 0 ) && (i< ArraySize (color_i))) col1=color_i[i];

         color col2=color_i2[ 0 ];
         if ((i>= 0 ) && (i< ArraySize (color_i2))) col2=color_i2[i];

         ObjectSet (name, OBJPROP_COLOR ,col1);
         ObjectSet (name, OBJPROP_STYLE , STYLE_DOT );
         ObjectSet (name, OBJPROP_RAY ,luch);

         if (maxmin== true )
             ObjectCreate (name+ " UP" , OBJ_TREND , 0 ,x2,(y2+ Point *Kanals[i][ 7 ]),x1,(y1+ Point *Kanals[i][ 7 ]));
         else
             ObjectCreate (name+ " UP" , OBJ_TREND , 0 ,x2,(y2+k_shirina* Point *Kanals[i][ 0 ]),x1,(y1+k_shirina* Point *Kanals[i][ 0 ]));
         ObjectSet (name+ " UP" , OBJPROP_RAY , FALSE );
         ObjectSet (name+ " UP" , OBJPROP_COLOR ,col1);
         ObjectSet (name+ " UP" , OBJPROP_STYLE , STYLE_DASH );
         ObjectSet (name+ " UP" , OBJPROP_RAY ,luch);

         if (maxmin== true )
             ObjectCreate (name+ " DOWN" , OBJ_TREND , 0 ,x2,(y2+ Point *Kanals[i][ 8 ]),x1,(y1+ Point *Kanals[i][ 8 ]));
         else
             ObjectCreate (name+ " DOWN" , OBJ_TREND , 0 ,x2,(y2-k_shirina* Point *Kanals[i][ 0 ]),x1,(y1-k_shirina* Point *Kanals[i][ 0 ]));
         ObjectSet (name+ " DOWN" , OBJPROP_RAY , FALSE );
         ObjectSet (name+ " DOWN" , OBJPROP_COLOR ,col1);
         ObjectSet (name+ " DOWN" , OBJPROP_STYLE , STYLE_DASH );
         ObjectSet (name+ " DOWN" , OBJPROP_RAY ,luch);

         if (color_fill== true )
           {
             ObjectCreate (name+ " TRIUP" , OBJ_TRIANGLE , 0 ,x2,(y2+ Point *Kanals[i][ 7 ]),x1,(y1+ Point *Kanals[i][ 7 ]),x2,(y2+ Point *Kanals[i][ 8 ]));
             ObjectSet (name+ " TRIUP" , OBJPROP_COLOR ,col2);
             ObjectCreate (name+ " TRIDown" , OBJ_TRIANGLE , 0 ,x1,(y1+ Point *Kanals[i][ 7 ]),x1,(y1+ Point *Kanals[i][ 8 ]),x2,(y2+ Point *Kanals[i][ 8 ]));
             ObjectSet (name+ " TRIDown" , OBJPROP_COLOR ,col2);
           }

         if (! ObjectCreate ( "Vertical_9_" + DoubleToStr (i, 0 ), OBJ_VLINE , 0 ,x2, 8 )) Comment ( "Îøèáêà 0 = " , GetLastError ());
         ObjectSet ( "Vertical_9_" + DoubleToStr (i, 0 ), OBJPROP_COLOR ,col1);
         ObjectSet ( "Vertical_9_" + DoubleToStr (i, 0 ), OBJPROP_STYLE , STYLE_DOT );
        }
       else
        {
         if (! ObjectMove (name, 0 ,x2,y2)) Comment ( "Îøèáêà 1 = " , GetLastError ());
         if (! ObjectMove (name, 1 ,x1,y1)) Comment ( "Îøèáêà 2 = " , GetLastError ());

         if (maxmin== true )
           {
             ObjectMove (name+ " UP" , 0 ,x2,y2+ Point *Kanals[i][ 7 ]);
             ObjectMove (name+ " UP" , 1 ,x1,y1+ Point *Kanals[i][ 7 ]);

             ObjectMove (name+ " DOWN" , 0 ,x2,y2+ Point *Kanals[i][ 8 ]);
             ObjectMove (name+ " DOWN" , 1 ,x1,y1+ Point *Kanals[i][ 8 ]);

             if (color_fill== true )
              {
               ObjectMove (name+ " TRIUP" , 0 ,x2,(y2+ Point *Kanals[i][ 7 ]));
               ObjectMove (name+ " TRIUP" , 1 ,x1,(y1+ Point *Kanals[i][ 7 ]));
               ObjectMove (name+ " TRIUP" , 2 ,x2,(y2+ Point *Kanals[i][ 8 ]));

               ObjectMove (name+ " TRIDown" , 0 ,x1,(y1+ Point *Kanals[i][ 7 ]));
               ObjectMove (name+ " TRIDown" , 1 ,x1,(y1+ Point *Kanals[i][ 8 ]));
               ObjectMove (name+ " TRIDown" , 2 ,x2,(y2+ Point *Kanals[i][ 8 ]));
              }
           }
         else
           {
             ObjectMove (name+ " UP" , 0 ,x2,y2+k_shirina* Point *Kanals[i][ 0 ]);
             ObjectMove (name+ " UP" , 1 ,x1,y1+k_shirina* Point *Kanals[i][ 0 ]);

             ObjectMove (name+ " DOWN" , 0 ,x2,y2-k_shirina* Point *Kanals[i][ 0 ]);
             ObjectMove (name+ " DOWN" , 1 ,x1,y1-k_shirina* Point *Kanals[i][ 0 ]);
           }
        }

     }
   return ( 0 );
  }
////////////////////////////////////////////////////////
int AllCanals()
  {
   int i1= 0 ,i2,i3;
   int k= 0 ;
   int i= 0 ;
   int lastper;
   int St,Fin;
   datetime S,F,prevS,CurStart;
   int lastmin;
   double lmin;
   double premin;
//ArrayInitialize(Kanals,0);
   lastper= 9 ;

   CurStart= iTime ( NULL , Period (),Start);
   if (Start== 0 ) CurStart= iTime ( NULL , 1 , 0 );
   prevS= iTime ( NULL ,p[ 0 ],( iBarShift ( NULL ,p[ 0 ],CurStart, FALSE )+BarAnaliz));
//ArrayInitialize(Vertikal,0);
//ArrayInitialize(Shir,0);

   for ( int jj= 0 ;jj<lastper;jj++)
     {
       //ArrayInitialize(Shirina,0);
       if (jj== 8 )
         S = CurStart;
       else S= iTime ( NULL ,p[jj+ 1 ],( iBarShift ( NULL ,p[jj+ 1 ],CurStart, FALSE )+BarAnaliz));
      F=prevS;
      prevS=S;
      St= iBarShift ( NULL ,p[jj],CurStart, FALSE );
      Fin= iBarShift ( NULL ,p[jj],F, FALSE );

       if (St== 0 && Fin== 0 )   return ( 0 );
       if (jj!= 8 ) {ArrShirina(St,Fin,( iBarShift ( NULL ,p[jj],S, FALSE ))-St- 7 ,p[jj]); } //Print("1111111111  ",p[jj],"   ", St,"   ", Fin,"   ",(iBarShift(NULL,p[jj],S,FALSE))-St-7);}
       else   {ArrShirina(St,Fin, 0 ,p[jj]);} // Print("888888888  ",p[jj],"   ", St,"   ", Fin);}
      lastmin=Fin+ 1 ;
       if (jj== 0 ) lmin= 10000000 ;
       if (jj== 0 ) premin=Shirina[Fin-St- 1 ];
       // Print(Start,"  ",p[jj],"  Ñòàðò - ",(iBarShift(NULL,p[jj],S,FALSE)),"  Ôèíèø - ",Fin);
       if (Fin> iBarShift ( NULL ,p[jj],S, FALSE ))
         for (i=Fin- 1 ; i>( iBarShift ( NULL ,p[jj],S, FALSE ))- 1 ; i--)
           {
             if ( iTime ( NULL , 0 , Bars - 1 )<= iTime ( NULL ,p[jj],i))
              {
               i3= iBarShift ( NULL , 0 , iTime ( NULL ,p[jj],i), FALSE );
               for (i2= 0 ;i2<=p[jj]/ Period ();i2++)
                 {
                   if (((i3-i2)>= 0 ) && ((i3-i2)< ArraySize (Shir)))
                     if (((i-St)>= 0 ) && ((i-St)< ArraySize (Shirina)))
                       {
                        Shir[i3-i2]=Shirina[i-St];
                       }
                 }
              }

             if (((i-St)>= 0 ) && ((i-St)< ArraySize (Shirina)))
              {
               if (Shirina[i-St]<lmin) {lmin=Shirina[i-St];lastmin=i;}
              }

             if (((i-St)>= 0 ) && ((i-St)< ArraySize (Shirina)))
               if ((((i-St- 1 )>= 0 ) && ((i-St- 1 )< ArraySize (Shirina))) && (((i-St+ 1 )>= 0 ) && ((i-St+ 1 )< ArraySize (Shirina))))
                   if (Shirina[i-St]<=Shirina[i-St- 1 ] && Shirina[i-St]<=Shirina[i-St+ 1 ])
                    {
                     if (lastmin==i)
                       {
                         if (Shirina[i-St]<premin*filtr && Shirina[i-St]>MinShirina && Shirina[i-St]<MaxShirina)
                          {
                           if (i1> 0 ) for (k= 0 ; k<i1; k++)
                             {
                               if (Shirina[i-St]!= 0 ) if ((Kanals[k][ 0 ]/Shirina[i-St])< 1.2 && (Kanals[k][ 0 ]/Shirina[i-St])> 0.8 ) i1=k;
                             }
                           if ( iTime ( NULL , 0 , Bars - 1 )<= iTime ( NULL ,p[jj],i)) Vertikal[i1]=i3;
                           Kanals[i1][ 0 ]= Shirina[i-St];
                           Kanals[i1][ 1 ]= i;
                           Kanals[i1][ 2 ]= p[jj];
                           Kanals[i1][ 3 ]= CanalR[i-St];
                           Kanals[i1][ 4 ]= CanalL[i-St];
                           if ((i-St)*p[jj]!= 0 ) Kanals[i1][ 5 ]=(CanalR[i-St]-CanalL[i-St])/((i-St)*p[jj]);
                           Kanals[i1][ 6 ]= (i-St);
                           Kanals[i1][ 7 ]= ShirinaU[i-St];
                           Kanals[i1][ 8 ]= ShirinaD[i-St];
                           premin=Shirina[i-St];
                           i1++;
                          }
                       }
                    }
           }
     }
   return (i1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//////////////////////////////////////////////////////////////////////
double ArrShirina( int Start1, int Finish, int Sdvig, int per)
  {
   Shirina[ 0 ]= 0 ;
   if (Sdvig< 0 ) Sdvig= 0 ;
   yOptR= iOpen ( NULL ,per,Start1);

   int d,i1;
   double dC,dR,dL;
   int p= 0 ;
   int lnz=Sdvig;
//Print("Start  ",Start1,"Finish   ",Finish);
   for ( int i=( 1 +Sdvig); i<(Finish-Start1); i++)
     {
       //x2 = iTime(NULL,per,i);
       if (tochnost!= 0 ) p= MathFloor ((i- 1 )/tochnost);
      i=i+p;
      Shirina[i]=MinCanal2(Start1,i+Start1,per);

       if (maxmin== true )
        {
         if ( k_shirina*Shirina[i]<curdeltaMax/ Point ) ShirinaU[i]=(curdeltaMax/ Point +k_shirina*Shirina[i])/ 2 ; else ShirinaU[i]=curdeltaMax/ Point ;
         if (-k_shirina*Shirina[i]>curdeltaMin/ Point ) ShirinaD[i]=(curdeltaMin/ Point -k_shirina*Shirina[i])/ 2 ; else ShirinaD[i]=curdeltaMin/ Point ;
        }
      CanalL[i]  = yOptL;
      CanalR[i]  = yOptR;
      d=i-lnz;
       if (d!= 0 )
        {
         dC=(Shirina[i]-Shirina[lnz])/d;
         dR=(CanalR[i]-CanalR[lnz])/d;
         dL=(CanalL[i]-CanalL[lnz])/d;
        }
       if (d> 1 )
         for (i1= 1 ;i1<d;i1++)
           {
            Shirina[lnz+i1] = Shirina[lnz+i1- 1 ]+dC;
            CanalL[lnz+i1]  = CanalL[lnz+i1- 1 ]+dL;
            CanalR[lnz+i1]  = CanalR[lnz+i1- 1 ]+dR;
           }
      lnz=i;
     }
   return ( 0 );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
///////////////////////////////////////////////////////
double MinCanal2( int xR, int xL, int per)
  {
   double p=xL-xR;
   double j1,j2,j3,h1,h2,yR,yL,d;

   j1 = p + 1 ;
   j2 = p*(p+ 1 )/ 2 ;
   j3 = p*(p+ 1 )*( 2 *p+ 1 )/ 6 ;


   if (prevxR!=xR || prevper!=per)
     {
      prevp= 0 ;
      sum1= 0 ;
      sum2= 0 ;
     }

   for ( int n=prevp; n<=p; n++)
     {
      sum2+= iOpen ( NULL ,per,n+xR);
     }

   for (n=prevp; n<=p; n++)
     {
      sum1+= iOpen ( NULL ,per,n+xR)*n;
     }

   h2 = sum2;
   h1 = sum1;
   prevxR=xR;
   prevp=p+ 1 ;
   prevper=per;
   d=(j2*h2-j1*h1)/(j2*j2-j1*j3);
   yOptR = (h1-j3*d)/j2;
   yOptL = d*p+yOptR;

   return (SumPlus2(xL,xR,yOptR,yOptL,per)/j1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
///////////////////////////////////////////////////////

double SumPlus2( int xL1, int xR1, double yR1, double yL1, int per)
  {
   double curLinePrice,curdelta,curdeltaH,curdeltaL,delta;
   curdeltaMax=- 100000 ;
   curdeltaMin= 100000 ;
   int i = xR1;
   if (xL1==xR1) return ( 0 );
   if ((xL1-xR1)!= 0 ) delta = (yL1-yR1)/(xL1-xR1);
   curLinePrice = yR1;
   sumPlus= 0 ;
   while (i<=xL1)
     {
      curdelta= iOpen ( NULL ,per,i)-curLinePrice;
      curdeltaH = iHigh ( NULL ,per,i) - curLinePrice;
      curdeltaL = iLow ( NULL ,per,i) - curLinePrice;
       if (curdeltaMax<curdeltaH) curdeltaMax=curdeltaH;
       if (curdeltaMin>curdeltaL) curdeltaMin=curdeltaL;
       if (curdelta> 0 ) sumPlus=sumPlus+curdelta;
      curLinePrice=curLinePrice+delta;
      i++;
     }
   return (sumPlus/ Point );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
////////////////////////////////////////////////////////////////////////////////////
void LoadHist()
  {
   int iPeriod[ 9 ];
   iPeriod[ 0 ]= 1 ;
   iPeriod[ 1 ]= 5 ;
   iPeriod[ 2 ]= 15 ;
   iPeriod[ 3 ]= 30 ;
   iPeriod[ 4 ]= 60 ;
   iPeriod[ 5 ]= 240 ;
   iPeriod[ 6 ]= 1440 ;
   iPeriod[ 7 ]= 10080 ;
   iPeriod[ 8 ]= 43200 ;
   for ( int iii= 0 ;iii< 9 ;iii++)
     {
       datetime open= iTime ( Symbol (),iPeriod[iii], 0 );
       //datetime open = MarketInfo(Symbol(),MODE_TIME);
       int error= GetLastError ();
       //Comment("");
       while (error== 4066 )
        {
         Comment ( "Did not load historical data for " ,iPeriod[iii], " period, the indicator needs to be rebooted or move on to another timeframe" );
         Sleep ( 10000 );
         open = iTime ( Symbol (), iPeriod[iii], 0 );
         error= GetLastError ();
        }
     }
  }
//+------------------------------------------------------------------+

Obrigado.

Atenciosamente, oink

Arquivos anexados:
mchannels.mq4  18 kb
 

Olámntiwana/mladen,

encontrei um indicador simples e preciso da EA para isso ... qualquer um dos grandes codificadores pode fazer isso para a EA

que é o ponto Macd... eu o defini para 30 , 50, 9 está dando lucro decente... então eu planejei fazer isso automatizar... então eu preciso da EA para isso e a regra comercial é simplesmente eu digo aqui...
1. quando o ponto aparece e fica de 60 segundos a 90 segundos no mínimo, imediatamente, realize o comércio nessa direção vermelho - vender, azul - comprar em ordem de mercado..... sem esperar o tempo de fechamento da vela...
2. depois de tomada a troca colocando sl e esta sl é preço de acionamento +/-(preço de acionamento*0,5/100) e este preço de sl é até que a vela feche com aquele ponto.... suponha que antes que a vela feche o ponto desaparece significa que não há preocupação que a troca esteja a bordo com sl. bu depois feche a vela com ponto e depois mude sl para preço de ponto ....
suponha que algumas vezes a sl ocorrerá... mas nenhum ponto novo aparece... então se a sl atingir a qualquer momento, então espere a vela fechar e se a próxima vela chegar ao preço inicial de acionamento, faça o comércio novamente com as mesmas regras de menção
de entrada sl e sl mudança e tp...
3. take profit é 1 é preço de ativação+/-(preço de ativação*1,6/100)
[por exemplo, suponha que o preço é 100 e vender ponto significa que nosso tp 1 é 100-(100*1,6/100) se comprar ponto significa 100+ (100*1,6/100) ]
e tp 2 é preço de gatilho+/-(preço de gatilho*2,5/100)
tp 3 é preço de gatilho+/-(preço de gatilho*4,4/100)
no estágio de reserva 1 sl de trilha até [ preço de acionamento+/-(preço de acionamento*1/100)]
no estágio 2 da reserva sl para[ preço de acionamento+/-(preço de acionamento*2,1/100)]
no estágio 3 de reserva de trilha sl para [preço de acionamento+/-(preço de acionamento*3..9/100)]
nestas condições não se cumprir ...então reservar totalmente na próxima aparição do ponto e fazer o comércio de acordo com aquele próximo ponto.

estou planejando fazer no mercado indiano então faça o tamanho do lote ser 1 e múltiplos de 1 ..não como 0,01, 0,1

Arquivos anexados:
MACD_Dot.mq4  3 kb
MACD_Dot.JPG  87 kb
 
nishhhan:

Olámntiwana/mladen,

encontrei um indicador simples e preciso da EA para isso ... qualquer um dos grandes codificadores pode fazer isso para a EA

que é o ponto Macd... eu o defini para 30 , 50, 9 está dando lucro decente... então eu planejei fazer isso automatizar... então eu preciso da EA para isso e a regra comercial é simplesmente eu digo aqui...
1. quando o ponto aparece e fica de 60 segundos a 90 segundos no mínimo, imediatamente, realize o comércio nessa direção vermelho - vender, azul - comprar em ordem de mercado..... sem esperar o tempo de fechamento da vela...
2. depois de tomada a troca colocando sl e esta sl é preço de acionamento +/-(preço de acionamento*0,5/100) e este preço de sl é até que a vela feche com aquele ponto.... suponha que antes que a vela feche o ponto desaparece significa que não há preocupação que a troca esteja a bordo com sl. bu depois feche a vela com ponto e depois mude sl para preço de ponto ....
suponha que algumas vezes a sl ocorrerá... mas nenhum ponto novo aparece... então se a sl atingir a qualquer momento, então espere a vela fechar e se a próxima vela chegar ao preço inicial de acionamento, faça o comércio novamente com as mesmas regras de menção
de entrada sl e sl mudança e tp...
3. take profit é 1 é preço de ativação+/-(preço de ativação*1,6/100)
[por exemplo, suponha que o preço é 100 e vender ponto significa que nosso tp 1 é 100-(100*1,6/100) se comprar ponto significa 100+ (100*1,6/100) ]
e tp 2 é preço de gatilho+/-(preço de gatilho*2,5/100)
tp 3 é preço de gatilho+/-(preço de gatilho*4,4/100)
no estágio de reserva 1 sl de trilha até [ preço de acionamento+/-(preço de acionamento*1/100)]
no estágio 2 da reserva sl para[ preço de acionamento+/-(preço de acionamento*2,1/100)]
no estágio 3 de reserva de trilha sl para [preço de acionamento+/-(preço de acionamento*3..9/100)]
nestas condições não se cumprir ...então reservar totalmente na próxima aparição do ponto e fazer o comércio de acordo com esse próximo ponto.

estou planejando fazer no mercado indiano então faça o tamanho do lote ser 1 e múltiplos de 1 ..não como 0,01, 0,1

Isso é um simples macd. Você pode usar qualquer EA que use macd para isso (mesmo a amostra macd que vem com o metatrader quando você o instala)

A condição de 60 a 90 segundos não é possível (você não pode ter quando exatamente um sinal acontece, o que geralmente se faz é procurar um sinal em uma barra fechada para evitar sinais falsos). Todo o resto é bastante usual em qualquer EA (exceto o "preço de acionamento" não é viável - não é possível fixar os preços para uma EA, por isso são usados o tp e o sl, mas são relativos ao preço aberto e não alguns níveis de preços fixos).

 

Olá queridos programadores.

Estou fazendo experiências com o mql4 para, esperamos, um dia ser um bom programador. Meu problema agora tem a ver com a medição de carrapatos/pips.

Estou tendo um corretor de 5 dígitos e estou usando o seguinte código:

 High[i] > iCustom(NULL, PERIOD_CURRENT, "BBands", 20, 2, 1.00, 1, 1, 1000, 5, i) - 15 * myPoint //Candlestick High > BBands - fixed value

onde:

myPoint = Point();
   if(Digits() == 5)
     {
      myPoint *= 10;
     }

Claro que isto funciona em majores, mas por exemplo ouro isto me dará 1,5 pip ao invés de 15 e para dax me dará 0,15pip ao invés

Portanto, eu gostaria de multiplicar por 100 se o instrumento for XAU/USD e por 1000 se o instrumento for DE30.

Como posso atacar este problema?

Razão: