Discusión sobre el artículo "Explorando opciones para crear velas multicolores"

 

Artículo publicado Explorando opciones para crear velas multicolores:

En este artículo, abordaremos las distintas posibilidades de crear indicadores personalizados con velas, señalando sus correspondientes ventajas y desventajas.

La gran ventaja de este último método es que dispondremos de una interfaz de usuario más informativa, a pesar de que con ello aumentará significativamente el número de búferes necesarios. No obstante, podemos ampliar esta ventaja haciendo que nuestra regla de coloreado nos ofrezca no solo información sobre las reglas comerciales, sino también la distinción entre las velas alcistas y bajistas. Podemos hacer esto simplemente trabajando con los colores de los bordes y los rellenos de las velas que hemos visto anteriormente. Para cada diseño, querremos que los bordes y el relleno de las velas bajas sean del mismo color, mientras que para el relleno de las velas altas, usaremos el blanco para un recuadro de precios con fondo blanco, dando la así la ilusión de tener velas vacías.

Así, hemos alcanzado el objetivo de este artículo; es decir, hemos demostrado cómo crear reglas de coloreado según alguna regla comercial, aplicando esta a un gráfico de velas con y sin relleno. El resultado final de nuestro trabajo se muestra en la siguiente imagen.


Autor: Samuel Manoel De Souza

 
¡Excelente Tutorial, Samuel! ¡¡¡Parabéns e obrigado!!!
 
Excelente one.... mi palo de vela pensamiento es también una recta que puede hacer que alguien entienda poco sobre el término de comercio, creo que el rojo es vender, mientras que el verde es comprar, pero ellos samething cuando el verde sube a comprar, mientras que el rojo hacia abajo para vender, pero al final del punto de la línea de allí, el verde debe tener una marcha atrás y el rojo debe moverse, así, mientras que el amarillo es jughing hay precio. Así que en la puesta de este a la mql5, todo el mundo sabrá mi lenguaje de consulta (mi ql).
 

Hola Samuel,

Buena idea, pero no puedo hacer este trabajo. ¿Puedes presentar este ejemplo en este artículo?


Saludos cordiales,

 
como se podrian hacer velas de ticks de cualquier cantidad para operar futuros 
 
scalp-91 #:
como se podrian hacer velas de ticks de cualquier cantidad para operar futuros 

https://www.mql5.com/es/articles/60

Creación de indicadores de tick en MQL5
Creación de indicadores de tick en MQL5
  • www.mql5.com
En este artículo vamos a ver la creación de dos indicadores: el indicador de tick, que representa el gráfico de tick del precio, y el indicador de vela de tick, que representa las velas con el número de ticks especificados. Cada uno de los indicadores escribe los precios de llegada en un archivo y utiliza los datos guardados tras el reinicio del indicador (estos datos pueden ser usados también por los demás programas).
 
Muchas gracias tan didáctico..
 
cf23EA1l #:

Hola Samuel,

Buena idea, pero no puedo hacer este trabajo. ¿Puede presentar este ejemplo en este artículo?


Saludos cordiales,

//+------------------------------------------------------------------+
//|Velas de color.mq5
//|Copyright 2020, Samuel Manoel de Souza ||
//| https://www.mql5.com/pt/users/samuelmnl |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Samuel Manoel de Souza"
#property link      "https://www.mql5.com/pt/users/samuelmnl"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 12
#property indicator_plots   3
//--- parcela toro
#property indicator_label1  "bull"
#property indicator_type1   DRAW_CANDLES
#property indicator_color1  clrGreen,clrBlack,clrGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- oso de parcela
#property indicator_label2  "bear"
#property indicator_type2   DRAW_CANDLES
#property indicator_color2  clrRed,clrBlack,clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- gama de parcelas
#property indicator_label3  "wait"
#property indicator_type3   DRAW_CANDLES
#property indicator_color3  clrGold,clrBlack,clrGold
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- tampones indicadores
double         bullBuffer1[];
double         bullBuffer2[];
double         bullBuffer3[];
double         bullBuffer4[];
double         bearBuffer1[];
double         bearBuffer2[];
double         bearBuffer3[];
double         bearBuffer4[];
double         rangeBuffer1[];
double         rangeBuffer2[];
double         rangeBuffer3[];
double         rangeBuffer4[];

input int inpShift = 0; //Indicador Shift
input int inpBlue = 10;// Turno Azul
input int inpRed = 20; //Red Shift

//+------------------------------------------------------------------+
//| Función de inicialización del indicador personalizada |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(inpBlue <= 0)
     {
      Alert("Blue Shift must be greater then 0!");
      return INIT_PARAMETERS_INCORRECT;
     }
   if(inpRed <= inpBlue)
     {
      Alert("Red Shift must be greater then Blue Shift!");
      return INIT_PARAMETERS_INCORRECT;
     }
//--- asignación de búferes indicadores
   SetIndexBuffer(0, bullBuffer1, INDICATOR_DATA);
   SetIndexBuffer(1, bullBuffer2, INDICATOR_DATA);
   SetIndexBuffer(2, bullBuffer3, INDICATOR_DATA);
   SetIndexBuffer(3, bullBuffer4, INDICATOR_DATA);
   SetIndexBuffer(4, bearBuffer1, INDICATOR_DATA);
   SetIndexBuffer(5, bearBuffer2, INDICATOR_DATA);
   SetIndexBuffer(6, bearBuffer3, INDICATOR_DATA);
   SetIndexBuffer(7, bearBuffer4, INDICATOR_DATA);
   SetIndexBuffer(8, rangeBuffer1, INDICATOR_DATA);
   SetIndexBuffer(9, rangeBuffer2, INDICATOR_DATA);
   SetIndexBuffer(10, rangeBuffer3, INDICATOR_DATA);
   SetIndexBuffer(11, rangeBuffer4, INDICATOR_DATA);
//---Establecer que valor hacer las barras invisibles
   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0);
   PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0);
   PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, 0);
//---Establecer los valores de desplazamiento para cada barra
   PlotIndexSetInteger(0, PLOT_SHIFT, inpShift);
   PlotIndexSetInteger(1, PLOT_SHIFT, inpShift);
   PlotIndexSetInteger(2, PLOT_SHIFT, inpShift);
//---Desde donde se dibujan las barras
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, inpRed - 1);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, inpRed - 1);
   PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, inpRed - 1);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Función de iteración del indicador personalizada|
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
//---Si no hay barras suficientes, no calcular
   if(rates_total < inpRed)
     {
      return rates_total;
     }
//---Definir desde donde debemos empezar el cálculo
   int limit;
   if(prev_calculated < inpRed)
      limit = inpRed;
   else
      limit = prev_calculated - 1;
//---Bucle de cálculo principal
   for(int i = limit; i < rates_total; i++)
     {
      int shift = BarIndex2shift(i);
      double open = iOpen(_Symbol, _Period, shift);
      double high = iHigh(_Symbol, _Period, shift);
      double low = iLow(_Symbol, _Period, shift);
      double close = iClose(_Symbol, _Period, shift);
      double red = price[i - (inpRed)]; //Obtener el valor de la línea roja
      double blue = price[i - inpBlue]; //Obtener el valor de la línea azul
      double yellow = price[i];     //Obtener el valor de la línea amarilla
      //Existen tres banderas para este filtro
      //0 = vender, 1= esperar, 1 = comprar
      // podemos comprar si 2 líneas está por encima del rojo
      // podemos vender si 2 líneas está por debajo del rojo
      int direction = 0;
      direction += (yellow > red) ? 1 : 0; // Si Amarillo está por encima de Rojo, suma 1
      red = blue;
      blue = yellow;
      direction += (blue > red) ? 1 : 0; // Si Azul está por encima de Rojo, suma 1 .
      //Por defecto las barras no son visibles
      bullBuffer1[i] = 0;
      bullBuffer2[i] = 0;
      bullBuffer3[i] = 0;
      bullBuffer4[i] = 0;
      bearBuffer1[i] = 0;
      bearBuffer2[i] = 0;
      bearBuffer3[i] = 0;
      bearBuffer4[i] = 0;
      rangeBuffer1[i] = 0;
      rangeBuffer2[i] = 0;
      rangeBuffer3[i] = 0;
      rangeBuffer4[i] = 0;
      //Asignaremos valor a cada barra según la bandera de dirección
      switch(direction)
        {
         case 0: // Es mercado bajista
           {
            bearBuffer1[i] = open;
            bearBuffer2[i] = high;
            bearBuffer3[i] = low;
            bearBuffer4[i] = close;
            break;
           }
         case 1: // Es mercado alcista
           {
            rangeBuffer1[i] = open;
            rangeBuffer2[i] = high;
            rangeBuffer3[i] = low;
            rangeBuffer4[i] = close;
            break;
           }
         case 2: // Es rango mercado
           {
            bullBuffer1[i] = open;
            bullBuffer2[i] = high;
            bullBuffer3[i] = low;
            bullBuffer4[i] = close;
            break;
           }
        }
     }
//--- valor de retorno de prev_calculado para la siguiente llamada
   return(rates_total);
  }

int BarIndex2shift(int bar) {return Bars(_Symbol, _Period) - bar - 1;}

//+------------------------------------------------------------------+
 
//+------------------------------------------------------------------+
//|Velas de colores.mq5
//| Copyright 2020, Samuel Manoel de Souza |
//| https://www.mql5.com/es/users/samuelmnl |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Samuel Manoel de Souza"
#property link      "https://www.mql5.com/es/users/samuelmnl"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 12
#property indicator_plots   3
//--- parcela toro
#property indicator_label1  "bull"
#property indicator_type1   DRAW_CANDLES
#property indicator_color1  clrGreen,clrBlack,clrGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- oso de parcela
#property indicator_label2  "bear"
#property indicator_type2   DRAW_CANDLES
#property indicator_color2  clrRed,clrBlack,clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- gama de parcelas
#property indicator_label3  "wait"
#property indicator_type3   DRAW_CANDLES
#property indicator_color3  clrGold,clrBlack,clrGold
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- tampones indicadores
double         bullBuffer1[];
double         bullBuffer2[];
double         bullBuffer3[];
double         bullBuffer4[];
double         bearBuffer1[];
double         bearBuffer2[];
double         bearBuffer3[];
double         bearBuffer4[];
double         rangeBuffer1[];
double         rangeBuffer2[];
double         rangeBuffer3[];
double         rangeBuffer4[];

input int inpShift = 0; //Indicador Shift
input int inpBlue = 10;// Turno Azul
input int inpRed = 20; //Red Shift

//+------------------------------------------------------------------+
//| Función de inicialización del indicador personalizada |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(inpBlue <= 0)
     {
      Alert("Blue Shift must be greater then 0!");
      return INIT_PARAMETERS_INCORRECT;
     }
   if(inpRed <= inpBlue)
     {
      Alert("Red Shift must be greater then Blue Shift!");
      return INIT_PARAMETERS_INCORRECT;
     }
//--- asignación de búferes indicadores
   SetIndexBuffer(0, bullBuffer1, INDICATOR_DATA);
   SetIndexBuffer(1, bullBuffer2, INDICATOR_DATA);
   SetIndexBuffer(2, bullBuffer3, INDICATOR_DATA);
   SetIndexBuffer(3, bullBuffer4, INDICATOR_DATA);
   SetIndexBuffer(4, bearBuffer1, INDICATOR_DATA);
   SetIndexBuffer(5, bearBuffer2, INDICATOR_DATA);
   SetIndexBuffer(6, bearBuffer3, INDICATOR_DATA);
   SetIndexBuffer(7, bearBuffer4, INDICATOR_DATA);
   SetIndexBuffer(8, rangeBuffer1, INDICATOR_DATA);
   SetIndexBuffer(9, rangeBuffer2, INDICATOR_DATA);
   SetIndexBuffer(10, rangeBuffer3, INDICATOR_DATA);
   SetIndexBuffer(11, rangeBuffer4, INDICATOR_DATA);
//---Establecer qué valor hace invisibles las barras
   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0);
   PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0);
   PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, 0);
//---Establecer los valores de desplazamiento para cada barra
   PlotIndexSetInteger(0, PLOT_SHIFT, inpShift);
   PlotIndexSetInteger(1, PLOT_SHIFT, inpShift);
   PlotIndexSetInteger(2, PLOT_SHIFT, inpShift);
//---Definir desde dónde deben dibujarse las barras
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, inpRed - 1);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, inpRed - 1);
   PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, inpRed - 1);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Función de iteración del indicador personalizada |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
//---Si no hay barras suficientes, no calcular
   if(rates_total < inpRed)
     {
      return rates_total;
     }
//---Definir desde donde debemos empezar el cálculo
   int limit;
   if(prev_calculated < inpRed)
      limit = inpRed;
   else
      limit = prev_calculated - 1;
//---Bucle de cálculo principal
   for(int i = limit; i < rates_total; i++)
     {
      int shift = BarIndex2shift(i);
      double open = iOpen(_Symbol, _Period, shift);
      double high = iHigh(_Symbol, _Period, shift);
      double low = iLow(_Symbol, _Period, shift);
      double close = iClose(_Symbol, _Period, shift);
      double red = price[i - (inpRed)]; //Obtener el valor de la línea roja
      double blue = price[i - inpBlue]; //Obtener el valor de la línea azul
      double yellow = price[i];     //Obtener el valor de la línea amarilla
      //Existen tres banderas para este filtro
      //0 = vender, 1= esperar, 1 = comprar
      // podemos comprar si 2 líneas está por encima del rojo
      // podemos vender si 2 líneas están por debajo del rojo
      int direction = 0;
      direction += (yellow > red) ? 1 : 0; // Si Amarillo está por encima de Rojo, suma 1
      red = blue;
      blue = yellow;
      direction += (blue > red) ? 1 : 0; // Si Azul está por encima de Rojo, suma 1 .
      //Por defecto las barras no son visibles
      bullBuffer1[i] = 0;
      bullBuffer2[i] = 0;
      bullBuffer3[i] = 0;
      bullBuffer4[i] = 0;
      bearBuffer1[i] = 0;
      bearBuffer2[i] = 0;
      bearBuffer3[i] = 0;
      bearBuffer4[i] = 0;
      rangeBuffer1[i] = 0;
      rangeBuffer2[i] = 0;
      rangeBuffer3[i] = 0;
      rangeBuffer4[i] = 0;
      //Asignaremos valor a cada barra según la bandera de dirección
      switch(direction)
        {
         case 0: // Es mercado bajista
           {
            bearBuffer1[i] = open;
            bearBuffer2[i] = high;
            bearBuffer3[i] = low;
            bearBuffer4[i] = close;
            break;
           }
         case 1: // Es mercado alcista
           {
            rangeBuffer1[i] = open;
            rangeBuffer2[i] = high;
            rangeBuffer3[i] = low;
            rangeBuffer4[i] = close;
            break;
           }
         case 2: // Es rango mercado
           {
            bullBuffer1[i] = open;
            bullBuffer2[i] = high;
            bullBuffer3[i] = low;
            bullBuffer4[i] = close;
            break;
           }
        }
     }
//--- valor de retorno de prev_calculado para la siguiente llamada
   return(rates_total);
  }

int BarIndex2shift(int bar) {return Bars(_Symbol, _Period) - bar - 1;}

//+------------------------------------------------------------------+
 
Gracias por este artículo, he podido seguirlo y aplicarlo a mis gráficos. Mi pregunta es ¿has hecho algún artículo que explique, cómo llamar a este indicador en un EA para utilizarlo para hacer automáticamente el comercio, así como probador de estrategias con la visualización?
 
PanteraNoire probador de estrategias con la visualización?

No.

Necesitas usar iCustom. Y usted puede ver los números de búfer en el indicador para saber acerca de los colores y valores.