Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 697

 


#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
//extern double    TakeProfit=250.0;
//extern double    Lots=1;
extern int       barn=1000;
extern int       Length=10;
extern int       PatternLength=10;
extern int        PatternWidth=4;
extern color       PatternColor = Red;
extern bool       DrawZigZag = true;
extern bool    ShowValues = true;
extern color   ValueColor = Blue;
//---- buffers
double ExtMapBuffer1[];
//double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexEmptyValue(0,0.0);
  //SetIndexDrawBegin(0, barn);
  if (DrawZigZag == true)  {SetIndexStyle(0,DRAW_SECTION);}
  else {SetIndexStyle(0,DRAW_NONE);}
   SetIndexBuffer(0,ExtMapBuffer1);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
ObjectsDeleteAll();
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 
   int shift,Swing,Swing_n,alf,uzl,i,zu,zd,mv;
   double LL,HH,BH,BL,NH,NL; 
   double Uzel[10000][3]; 
   string text;
    
    ObjectDelete(OBJ_TREND);
    

// loop from first bar to current bar (with shift=0) 
      Swing_n=0;Swing=0;uzl=0; 
      BH =High[barn];BL=Low[barn];zu=barn;zd=barn; 



for (shift=barn;shift>=0;shift--) { 
      LL=10000000;HH=-100000000; 
   for (i=shift+Length;i>=shift+1;i--) { 
         if (Low[i]< LL) {LL=Low[i];
           
         } 
         if (High[i]>HH) {HH=High[i];} 

  }
 
   if (Low[shift]<LL && High[shift]>HH){ 
      Swing=2; 
      if (Swing_n==1) {zu=shift+1;} 
      if (Swing_n==-1) {zd=shift+1;
 
      } 
      
   } else { 
      if (Low[shift]<LL) {Swing=-1;} 
      if (High[shift]>HH) {Swing=1;} 
   } 

   if (Swing!=Swing_n && Swing_n!=0) { 
   if (Swing==2) {
      Swing=-Swing_n;BH = High[shift];BL = Low[shift]; 
   } 
   uzl=uzl+1; 
   if (Swing==1) {
      Uzel[uzl][1]=zd;
      Uzel[uzl][2]=BL;
      NewSid(i,zd,BL);
     
   } 
   if (Swing==-1) {
      Uzel[uzl][1]=zu;
      Uzel[uzl][2]=BH; 
       NewSid(i,zu,BH);
   } 
      BH = High[shift];
      BL = Low[shift]; 
      

   } 
 
   
/*

 */
   
   

   if (Swing==1) { 
      if (High[shift]>=BH) {BH=High[shift];zu=shift;}} 
      if (Swing==-1) {
          if (Low[shift]<=BL) {BL=Low[shift]; zd=shift;}} 
      Swing_n=Swing; 
   } 

   

   
   for (i=1;i<=uzl;i++) { 
         mv=StrToInteger(DoubleToStr(Uzel[i][1],0));
      ExtMapBuffer1[mv]=Uzel[i][2];
      

   
   } 


   return(0);
  }
  
  void NewSid(int i, int re,  double Uzels)
{

int zed=re-PatternLength;

if (zed < 0)
   {
   ObjectCreate("priceLine1_"+i,OBJ_TREND,0,0,0,0,0);
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME1,Time[re]);
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE1,Uzels);
  
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME2,Time[re+PatternLength]); 
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE2,Uzels);   
    
   ObjectSet("priceLine1_"+i ,OBJPROP_COLOR,PatternColor);
   ObjectSet("priceLine1_"+i,OBJPROP_RAY, false);
   ObjectSet("priceLine1_"+i,OBJPROP_WIDTH,PatternWidth);
   

   }
   
   
   
   
  else {

   ObjectCreate("priceLine1_"+i,OBJ_TREND,0,0,0,0,0);
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME1,Time[re]);
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE1,Uzels);
  
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME2,Time[re-PatternLength]); 
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE2,Uzels);   
    
   ObjectSet("priceLine1_"+i ,OBJPROP_COLOR,PatternColor);
   ObjectSet("priceLine1_"+i,OBJPROP_RAY, false);
   ObjectSet("priceLine1_"+i,OBJPROP_WIDTH,PatternWidth);
}

      string high  = DoubleToStr(High[re],4);
      string low   = DoubleToStr(Low[re],4);
      string open  = DoubleToStr(Open[re],4);
      string close = DoubleToStr(Close[re],4);

 Comment(low,"   ",high);

if (ShowValues == true)

{
   ObjectCreate("price_text"+i,OBJ_TEXT,0,0,0);
   //ObjectSetText("price_text"+i,"Date: "+TimeToStr(Time[re],TIME_DATE | TIME_MINUTES)+" | Time: ",10,"Calibri", Green);
   
   ObjectSetText("price_text"+i,"Open: "+open+" | High: "+high+" | Low: "+low+" | Close: "+close,10,"Calibri", ValueColor);
   ObjectSet("price_text"+i ,OBJPROP_TIME1,Time[re]);
   ObjectSet("price_text"+i ,OBJPROP_PRICE1,Uzels);
   
};
}


Por qué sale Comment(low," ",high);
¿sólo el valor alto?
 
¿Puede alguien aconsejar cómo establecer restricciones en el texto del indicador para su uso en diferentes marcos de tiempo. Al cargar el indicador está en las propiedades, pero cómo limitarlo programáticamente????
 
Vladimir Pavlov:
¿Pueden aconsejar cómo poner restricciones al uso de diferentes plazos en el texto del indicador? Al cargar el indicador se encuentra en las propiedades, pero cómo limitar esto programáticamente????
if(InpTimeframeWork!=Period())
  {
   // Здесь действия, которые нужно выполнить если период графике не совпадает с заданным в настройках
  }

Si se comprueba en OnInit(), se puede emitir un mensaje sobre el desajuste del gráfico y devolver INIT_FAILED; o ajustar el gráfico terminal al deseado: ChartSetSymbolPeriod(0,NULL,InpTimeframeWork);

 

¡Buenas tardes!
Por favor, ayúdenme con el problema de la activación de la copiadora. Hace tiempo compré una copiadora en el mercado por 25 dólares. Me gustaría usarlo en VPS pero no puedo descargarlo del mercado en MT4 por alguna razón. Ofertas sólo para comprar. Todavía tengo 7 activaciones gratuitas. No consigoaveriguar qué es lo que falla, ¿pueden aconsejarme qué debo hacer para activar la copiadora https://www.mql5.com/ru/market/product/4319?

Gracias de antemano.

 
Artyom Trishkin:

Si se comprueba en OnInit(), se puede emitir un mensaje sobre el desajuste del gráfico y devolver INIT_FAILED; o ajustar el gráfico terminal al requerido: ChartSetSymbolPeriod(0,NULL,InpTimeframeWork);

Conozco esta variante, pero no sé cómo utilizar las propiedades. Cómo configurar en la pestaña del programa "Pantalla" para no dejar entrar niveles innecesarios.

 
//+------------------------------------------------------------------+
//|| eeeeee.mq4 ||
//| Copyright 2018, MetaQuotes Software Corp.
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#enlace de propiedad "https://www.mql5.com"
#versión de la propiedad "1.00"
#propiedad estricta
#propiedad ventana_del_gráfica_del_indicador
extern int ExtDepth = 12;
extern int DesviaciónExt = 5;
extern int ExtBackstep = 3;
extern inttern ShiftBars = 2;
//+------------------------------------------------------------------+
//| Función de inicialización de indicadores personalizada |
//+------------------------------------------------------------------+
int OnInit()
{// en el módulo

//en la función
double y3=0, y2=0, y1=0, zz; // extremos
int x3, x2, x1, sh=ShiftBars;// número de barras
// Toma tres extremos del Zig-Zag
while (y3==0) {
zz=iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, sh);
if (zz!=0 && zz!=EMPTY_VALUE) {
if (y1==0) { x1=sh; y1=zz; }
else if (y2==0) { x2=sh; y2=zz; }
else if (y3==0) { x3=sh; y3=zz; }
}
sh++;

}

¿Cómo se obtiene el valor del extremo actual?

Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
  • www.mql5.com
Задавайте вопросы по техническому анализу, обсуждайте торговые системы и улучшайте свои навыки программирования торговых стратегий на языке MQL5. Общайтесь и обменивайтесь опытом на форуме с трейдерами всего мира и помогайте ответами новичкам — наше сообщество развивается вместе с вами. Как эффективно продвигать свой продукт в Маркете...
 
02031986dima:

¿Cómo obtener el valor del extremo actual?

Introduzca el código correctamente:


 
02031986dima:
//+------------------------------------------------------------------+
//|| eeeeee.mq4 ||
//| Copyright 2018, MetaQuotes Software Corp.
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#enlace de propiedad "https://www.mql5.com"
#versión de la propiedad "1.00"
#propiedad estricta
#propiedad ventana_del_gráfica_del_indicador
extern int ExtDepth = 12;
extern int DesviaciónExt = 5;
extern int ExtBackstep = 3;
extern inttern ShiftBars = 2;
//+------------------------------------------------------------------+
//| Función de inicialización de indicadores personalizada |
//+------------------------------------------------------------------+
int OnInit()
{// en el módulo

//en la función
double y3=0, y2=0, y1=0, zz; // extremos
int x3, x2, x1, sh=ShiftBars;// número de barras
// Toma tres extremos del Zig-Zag
while (y3==0) {
zz=iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, sh);
if (zz!=0 && zz!=EMPTY_VALUE) {
if (y1==0) { x1=sh; y1=zz; }
else if (y2==0) { x2=sh; y2=zz; }
else if (y3==0) { x3=sh; y3=zz; }
}
sh++;

}

¿Cómo se obtiene el valor del extremo actual?

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Возвращает экстремум ЗигЗага по его номеру.                    |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL или "" - текущий символ)          |
//|    tf - таймфрейм                  (      0     - текущий ТФ)              |
//|    ne - номер экстремума           (      0     - последний)               |
//|    dp - ExtDepth                                                           |
//|    dv - ExtDeviation                                                       |
//|    bs - ExtBackstep                                                        |
//+----------------------------------------------------------------------------+
double GetExtremumZZPrice(string sy="", int tf=0, int ne=0, int dp=12, int dv=5, int bs=3) {
  if (sy=="" || sy=="0") sy=Symbol();
  double zz;
  int    i, k=iBars(sy, tf), ke=0;

  for (i=0; i<k; i++) {
    zz=iCustom(sy, tf, "ZigZag", dp, dv, bs, 0, i);
    if (zz!=0) {
      ke++;
      if (ke>ne) return(zz);
    }
  }
  Print("GetExtremumZZPrice(): Экстремум ЗигЗага номер ",ne," не найден");
  return(0);
}
 

¿cuántos archivos adjuntos se permiten?

if
{
   if
     {

     }
}
 
multiplicator:

¿cuántos archivos adjuntos se permiten?

Hasta que te canses de escribirlas

Razón de la queja: