Ayuda a la codificación - página 672

 
mladen:

NWFstudent

Por qué no usas el código fuente original para empezar (el indicador de parada de bb siempre fue gratis, no hay necesidad de usar la versión descompilada, y es mucho más fácil trabajar con el código original)

Gracias por su consejo Sr. mladen.

¿Dónde puedo encontrar el código original?

EDIT: Creo que lo he encontrado, mucho más limpio código legible, gracias un tiempo de miles.

Esto es lo correcto?:

//+------------------------------------------------------------------+
//|                                               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:

Gracias por su consejo Sr. mladen.

¿Dónde puedo encontrar el código original?

EDIT: Creo que lo he encontrado, mucho más limpio código legible, gracias un tiempo de miles.

Esto es lo correcto?:

Sí, es el mismo :)
 
NWFstudent:

Gracias por su consejo Sr. mladen.

¿Dónde puedo encontrar el código original?

EDIT: Creo que lo he encontrado, mucho más limpio código legible, gracias un tiempo de miles.

¿Esto es lo correcto?

NWFstudent

Creo que esto de la barra limitada de MLADENs y esto de la línea de MRTOOLs son versiones más actuales y con formato mq4.

saludos


 

Mladen

Estoy tratando de conseguir el TMA mtf para trabajar en mi EA. Conseguí que la "tma centrada" que cruza la 200ma funcione pero el 1 &-1 de la mtf parece ser anterior por alguna razón & oportuna, ver mi gráfico.

Puedes comprobar mi EA. Ahora mismo está configurado para operar en el búfer de tendencia "TMA mtf" #3. Se compila y se ejecuta en el probador, pero no hay operaciones y no hay errores. El único cambio que hice al TMA mtf es añadir el SetIndexLabels. Si cargo ambos indicadores tmas en un gráfico se reflejan el uno al otro.

Aprecio cualquier ayuda

Ray

 
traderduke:

Mladen

Estoy tratando de conseguir el TMA mtf para trabajar en mi EA. Conseguí que la "tma centrada" que cruza la 200ma funcione pero el 1 &-1 de la mtf parece ser anterior por alguna razón & oportuna, ver mi gráfico.

Puedes comprobar mi EA. Ahora mismo está configurado para operar en el búfer de tendencia "TMA mtf" #3. Se compila y se ejecuta en el probador, pero no hay operaciones y no hay errores. El único cambio que hice al TMA mtf es añadir el SetIndexLabels. Si cargo ambos indicadores tmas en un gráfico se reflejan el uno al otro.

Aprecio cualquier ayuda

Ray

Ese es un problema de los indicadores de recálculo/repintado. No se pueden utilizar para las señales. Echa un vistazo a la forma en que funciona en tiempo de ejecución, y entonces usted verá por qué no puede trabajar con esa lógica en el EA
 
dotmund:
Encontré este indicador en este sitio y me pareció útil pls puede ayudarme a hacer un EA de ella y hacer que el comercio immdiately cuando la flecha aparece y cerrar el cierre de la vela siguiente lo que significa que el comercio sólo dos velas y debe cerrar si la flecha opuesta aparecen. pls
por favor ayudenme con esto.
 

Hola juntos.

¿Alguien puede ayudarme a agregar este indicador de canal, cómo puedo ocultar los canales superiores?

Solo necesito M1, M5, M15 y no entiendo este 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 ();
        }
     }
  }
//+------------------------------------------------------------------+

Gracias.

Saludos, oink

Archivos adjuntos:
mchannels.mq4  18 kb
 

Holamntiwana/mladen,

Encontré un indicador simple y necesito EA para él ... puede cualquiera de un gran codificador puede hacer esto a EA

es el punto Macd... lo puse a 30, 50, 9 está dando un beneficio decente... así que planeé hacer esto automatizado... así que necesito EA para esto y la regla de comercio es simplemente digo aquí...
1. cuando el punto aparece y se mantiene durante un mínimo de 60 segundos a 90 segundos inmediatamente tomar el comercio en esa dirección rojo - vender, azul - comprar en el mercado order..... no esperar a que el tiempo de cierre de la vela ...
2. después de tomar el comercio colocando sl y este sl es el precio de activación+/-(precio de activación*0.5/100) y este precio sl es hasta que la vela se cierre con ese punto.... suponga que antes de cerrar la vela el punto desaparece significa que no hay que preocuparse el comercio está a bordo con sl. bu entonces la vela se cierra con el punto entonces cambia sl al precio del punto ....
Supongamos que algunas veces sl tendrá lugar .. pero no aparece ningún punto fresco .. así que si sl golpea por cualquier momento entonces esperar a que la vela de cierre y si la próxima vela viene al precio de disparo inicial tomar el comercio de nuevo con la misma mención reglas
de entrada sl y cambio sl y tp...
3. take profit es 1 es el precio de activación+/-(precio de activación*1.6/100)
[por ejemplo supongamos que el precio es 100 y el punto de venta significa que nuestro tp 1 es 100-(100*1.6/100) si el punto de compra significa 100+ (100*1.6/100) ]
y tp 2 es precio de activación+/-(precio de activación*2.5/100)
tp 3 es el precio de activación+/-(precio de activación*4,4/100)
en la fase de reserva 1, el rastro de sl es [ precio de activación+/-(precio de activación*1/100)].
en la fase de reserva 2 trail sl a[ precio de activación+/-(precio de activación*2,1/100)]
en la etapa de reserva 3 trail sl a [precio de activación+/-(precio de activación*3..9/100)]
si estas condiciones no se cumplen ...entonces reserve completamente en la siguiente aparición de puntos y haga la operación según ese siguiente punto.

Estoy planeando hacer en el mercado indio para hacer el tamaño del lote es 1 y múltiplos de 1 .. no como 0,01, 0,1

Archivos adjuntos:
MACD_Dot.mq4  3 kb
MACD_Dot.JPG  87 kb
 
nishhhan:

Holamntiwana/mladen,

Encontré un indicador simple y necesito EA para él ... puede cualquiera de un gran codificador puede hacer esto a EA

es el punto Macd... lo puse a 30, 50, 9 está dando un beneficio decente... así que planeé hacer esto automatizado... así que necesito EA para esto y la regla de comercio es simplemente digo aquí...
1. cuando el punto aparece y se mantiene durante un mínimo de 60 segundos a 90 segundos inmediatamente tomar el comercio en esa dirección rojo - vender, azul - comprar en el mercado order..... no esperar a que el tiempo de cierre de la vela ...
2. después de tomar el comercio colocando sl y este sl es el precio de activación+/-(precio de activación*0.5/100) y este precio sl es hasta que la vela se cierre con ese punto.... suponga que antes de cerrar la vela el punto desaparece significa que no hay que preocuparse el comercio está a bordo con sl. bu entonces la vela se cierra con el punto entonces cambia sl al precio del punto ....
Supongamos que algunas veces sl tendrá lugar .. pero no aparece ningún punto fresco .. así que si sl golpea por cualquier momento entonces esperar a que la vela de cierre y si la próxima vela viene al precio de disparo inicial tomar el comercio de nuevo con la misma mención reglas
de entrada sl y cambio sl y tp...
3. take profit es 1 es el precio de activación+/-(precio de activación*1.6/100)
[por ejemplo supongamos que el precio es 100 y el punto de venta significa que nuestro tp 1 es 100-(100*1.6/100) si el punto de compra significa 100+ (100*1.6/100) ]
y tp 2 es precio de activación+/-(precio de activación*2.5/100)
tp 3 es el precio de activación+/-(precio de activación*4,4/100)
en la fase de reserva 1, el rastro de sl es [ precio de activación+/-(precio de activación*1/100)].
en la fase de reserva 2 trail sl a[ precio de activación+/-(precio de activación*2,1/100)]
en la etapa de reserva 3 trail sl a [precio de activación+/-(precio de activación*3..9/100)]
si estas condiciones no se cumplen ...entonces reserve completamente en la siguiente aparición de puntos y haga la operación según ese siguiente punto.

Estoy planeando hacer en el mercado indio para hacer el tamaño del lote es 1 y múltiplos de 1 .. no como 0,01, 0,1

Esto es un simple macd. Usted puede utilizar cualquier EA que utiliza macd para que (incluso la muestra macd que viene con el metatrader cuando se instala)

La condición de 60 a 90 segundos no es posible (no se puede tener cuando ocurre exactamente una señal, lo que se suele hacer en su lugar es buscar una señal en una barra cerrada para evitar falsas señales). Todo lo demás es bastante habitual en cualquier EA (excepto el "precio de activación" no es posible - no se pueden fijar los precios para un EA, por eso se utilizan el tp y el sl, pero son relativos al precio de apertura y no a unos niveles de precios fijos)

 

Hola queridos programadores.

Estoy experimentando con mql4 para esperar ser un buen programador algún día. Mi problema ahora tiene que ver con la medición de ticks/pips.

Im tener un corredor de 5 dígitos y están utilizando el siguiente 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

donde:

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

Por supuesto, esto funciona en los principales, pero por ejemplo el oro esto me dará 1,5 pip en lugar de 15 y para el dax me dará 0,15pip en lugar de

Así que me gustaría multiplicar por 100 si el instrumento es XAU/USD y por 1000 si el instrumento es DE30.

¿Cómo puedo atacar este problema?

Razón de la queja: