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

 
Carcass77:

Mi indicador funciona, sólo estoy ampliando.

De acuerdo, lo conseguiré yo mismo.

Si este es su indicador, la cuestión parece, por decirlo suavemente, alarmante...

 
Сергей Таболин:

Si este es su indicador, la cuestión parece, por decirlo suavemente, alarmante...

Está funcionando. La pregunta se refería a la "forma" de la declaración de la variable de cadena. Todavía estoy aprendiendo, si acaso, señores programadores.

 
Carcass77:

Ha funcionado. La pregunta se refería a la "forma" de la declaración de la variable de cadena. Todavía estoy aprendiendo, si acaso, señores programadores.

Todo el mundo está aprendiendo, es normal.

Mi pregunta surgió porque tu ejemplo no era de nivel de principiante, y la cuestión sobre los tipos de variables y el alcance es lo primero que tienes que entender cuando intentas escribir tu código por primera vez - sin entender esto, no conseguirás nada en el futuro

 
Carcass77:

Ha funcionado. La pregunta se refería a la "forma" de la declaración de la variable de cadena. Todavía estoy aprendiendo, si acaso, señores programadores.

Yo también sigo aprendiendo )))) Y espero poder seguir aprendiendo mucho ;)

 

Saludos a todos ¿Cómo pasar al botón , nombre + valor ( ejemplo botón Lots = 0.1 ) ?

Gracias de antemano.

 
Hola! Estoy intentando dibujar una línea de tendencia utilizando fractales inferiores y no funciona. Toma el inicio de los tiempos como primer punto, dibuja una línea y ya está. No pasa al siguiente fractal. ¿Qué estoy haciendo mal, cómo puedo solucionarlo?
datetime firsttime1;
datetime firsttime2;
datetime secondtime1;
datetime secondtime2;
double  firstprice1;
double  firstprice2;
double  secondprice1;
double  secondprice2;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  if(Hour()>=9 && Hour()<22)
   {
    Fun_New_Bar();
    if(New_Bar)      
     {

double vallo=iFractals(NULL,0,MODE_LOWER,2);Alert("vallo = ",vallo);
      {if(vallo>0)
       {
       //забиваем координаты второй точки для линии Low
       secondtime1=(TimeCurrent()-7200);
       secondprice1=iLow(NULL,0,2);
       
       //рисуем трендовую линию Low
       ObjectCreate("LowLine",OBJ_TREND,0,firsttime1,firstprice1,secondtime1,secondprice1);

      firsttime1=secondtime1;
      firstprice1=secondprice1;
   
       }
      }
     }
   }
  } 
 

Se han añadido flechas al indicador SuperTrend descargado de kodobase. Dibuja las flechas normalmente en el arranque,


pero si me desplazo hacia atrás/izquierda en el gráfico, aparece el galimatías y todo se bloquea.


Aquí está el código:

//+------------------------------------------------------------------+
//|                                                   SuperTrend.mq4 |
//|                   Copyright © 2008, Jason Robinson (jnrtrading). |
//|                                   http://www.spreadtrade2win.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Jason Robinson."
#property link      "http://www.spreadtrade2win.com"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 clrLime
#property indicator_color2 clrRed
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 3
#property indicator_width4 3

enum en_trend {
   Modern,   // Modern
   Classic,  // Classic
};

//+------------------------------------------------------------------+
//| Universal Constants                                              |
//+------------------------------------------------------------------+
#define  PHASE_NONE 0
#define  PHASE_BUY  1
#define  PHASE_SELL -1

//+------------------------------------------------------------------+
//| User input variables                                             |
//+------------------------------------------------------------------+
input en_trend TrendMode      = Modern;   // Trend Line Mode
input int      ATR_Period     = 10;       // ATR Period
input double   ATR_Multiplier = 3.0;      // ATR Multiplier
input int      BarsToCount    = 0;        // Bars to count (0 - all bars)
input color    clr_Up         = clrLime;  // Arrow Up Color
input color    clr_Dn         = clrRed;   // Arrow Down Color

//+------------------------------------------------------------------+
//| Universal variables                                              |
//+------------------------------------------------------------------+
double buffer_line_up[];
double buffer_line_down[];
double ArrowUpBuffer[];
double ArrowDnBuffer[];

double atr,
       band_upper,
       band_lower,
       shift;
int    phase=PHASE_NONE;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
   IndicatorShortName("Super Trend");
   IndicatorDigits((int)MarketInfo(Symbol(),MODE_DIGITS));
   SetIndexBuffer(0,buffer_line_up);
   SetIndexLabel(0,"Up Trend");
   SetIndexBuffer(1,buffer_line_down);
   SetIndexLabel(1,"Down Trend");

//--- 2 additional arrows buffers
//---- drawing settings
   SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,EMPTY,clr_Up);
   SetIndexArrow(2,233);
   SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,EMPTY,clr_Dn);
   SetIndexArrow(3,234);
//---- indicator buffers
   SetIndexBuffer(2,ArrowUpBuffer);
   SetIndexBuffer(3,ArrowDnBuffer);
   SetIndexEmptyValue(2,0.0);
   SetIndexEmptyValue(3,0.0);  
  
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   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+2;

   for(int i=limit; i>=0; i--) 
     {
      atr   = iATR(Symbol(),0,ATR_Period,i);
      shift = 0.5*iATR(Symbol(),0,100,i);;
      band_upper = (High[i]+Low[i])/2 + ATR_Multiplier * atr;
      band_lower = (High[i]+Low[i])/2 - ATR_Multiplier * atr;

      if(phase==PHASE_NONE) 
        {
         buffer_line_up[i]=(High[i+1]+Low[i+1])/2;
         buffer_line_down[i]=(High[i+1]+Low[i+1])/2;
        }

      if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i+1] && buffer_line_down[i+1]!=EMPTY_VALUE) 
        {
         phase = PHASE_BUY;
         buffer_line_up[i]=band_lower;
         buffer_line_up[i+1]=buffer_line_down[i+1];
        }

      if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i+1] && buffer_line_up[i+1]!=EMPTY_VALUE) 
        {
         phase = PHASE_SELL;
         buffer_line_down[i]=band_upper;
         buffer_line_down[i+1]=buffer_line_up[i+1];
        }

      if(phase==PHASE_BUY
         && ((TrendMode==0 && buffer_line_up[i+2]!=EMPTY_VALUE) || TrendMode==1)) 
        {
         if(band_lower>buffer_line_up[i+1]) 
           {
            buffer_line_up[i]=band_lower;
           }
         else 
           {
            buffer_line_up[i]=buffer_line_up[i+1];
           }
        }
      if(phase==PHASE_SELL
         && ((TrendMode==0 && buffer_line_down[i+2]!=EMPTY_VALUE) || TrendMode==1)) 
        {
         if(band_upper<buffer_line_down[i+1]) 
           {
            buffer_line_down[i]=band_upper;
           }
         else 
           {
            buffer_line_down[i]=buffer_line_down[i+1];
           }
        }
        
        // Make Arrows
        if (buffer_line_up[i+1]  !=EMPTY_VALUE && 
            buffer_line_up[i+2]  !=EMPTY_VALUE && 
            buffer_line_down[i+2]!=EMPTY_VALUE) {
           ArrowUpBuffer[i+1]=Low[i+1]-shift;
           ArrowDnBuffer[i+1]=0.0;

        }
        if (buffer_line_down[i+1] !=EMPTY_VALUE && 
            buffer_line_down[i+2] !=EMPTY_VALUE && 
            buffer_line_up[i+2]   !=EMPTY_VALUE) {
           ArrowDnBuffer[i+1]=High[i+1]+shift;
           ArrowUpBuffer[i+1]=0.0;

        }
     }

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

Por favor, dígame qué tiene de malo.

Supertrend
Supertrend
  • www.mql5.com
AudioPrice Revision 1 Have audio output of latest price in stereo! Revised to cater for fractional pips as now offered by some brokers to MT4. Stochastic Net Stochastic net for the the classification problems with the instruction provided.
Archivos adjuntos:
 
Grigori.S.B:

Por favor, dígame qué he hecho mal.

He cometido un error al insertar este complemento por separado. Las flechas deben ponerse sólo en el momento del cambio de búfer. Al mismo tiempo, no olvides poner un valor vacío en el buffer en todos los demás casos.

Mejor aún: poner un valor vacío a la vez, y llenar uno de los búferes con una flecha cuando la tendencia cambie.

 
Grigori.S.B:

pero si me desplazo hacia atrás/izquierda, aparece el galimatías y todo se rompe.

¿se está barriendo el historial? no tiene un recálculo para este caso y los nuevos elementos del buffer de indicadores que aparecen están llenos de basura.

 
¿Qué, me estoy perdiendo algo elemental de nuevo ya que nadie quiere responder?
Razón de la queja: