MQLArticles/Utils/Objects/Native/Imp.mqh
2026-10-21 22:39:41 -05:00

691 lines
40 KiB
MQL5

//+------------------------------------------------------------------+
//| Imp.mqh |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com"
#property strict
#ifndef MQLARTICLES_UTILS_OBJECTS_NATIVE_IMP_MQH
#define MQLARTICLES_UTILS_OBJECTS_NATIVE_IMP_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "Base.mqh"
//+------------------------------------------------------------------+
//| Implementacion de CNativeoGObjs (declarado en Base.mqh) |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
bool CNativeoGObjs::VLineCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre de la línea
const int sub_window, // índice de subventana
datetime time, // hora de la línea
const color clr, // color de la línea
const ENUM_LINE_STYLE style, // estilo de la línea
const int width, // grosor de la línea
const bool back, // al fondo
const bool selection, // seleccionar para mover
const bool ray,
const string& tooltip, // continuación de la línea abajo
const long z_order) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos la línea vertical
if(!ObjectCreate(chart_ID, name, OBJ_VLINE, sub_window, time, 0))
{
Print(__FUNCTION__,
": ¡Fallo al crear la línea vertical! Código del error = ", GetLastError());
return(false);
}
//--- establecemos el color de la línea
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el estilo de visualización de la línea
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
//--- establecemos el grosor de la línea
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de desplazamiento de la línea con ratón
//--- cuando el objeto gráfico se crea usando la función ObjectCreate, por defecto el objeto
//--- no se puede seleccionar y mover. Mientras que dentro de este método el parámetro selection
//--- por defecto es igual a true, lo que permite seleccionar y mover este objeto
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- activar (true) o desactivar (false) el modo de visualización de la línea en las subventanas del gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_RAY, ray);
//--- establecemos la prioridad para obtener el evento de cliquear sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
ObjectSetString(chart_ID, name, OBJPROP_TOOLTIP, tooltip);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::TrendCreate(long chart_ID, // ID del gráfico
const string& name, // Nombre de la línea
int sub_window, // índice de subventana
datetime time1, // hora del primer punto
double price1, // precio del primer punto
datetime time2, // hora del segundo punto
double price2, // precio del segundo punto
color clr, // color de la línea
ENUM_LINE_STYLE style, // estilo de la línea
int width, // grosor de la línea
bool back, // al fondo
bool selection, // seleccionar para mover
const string& tooltip
)
{
//--- establecemos las coordenadas de los puntos de anclaje si todavía no han sido establecidas
//--- anulamos el valor del error
ResetLastError();
//--- creamos la línea de tendencia según las coordenadas establecidas
if(!ObjectCreate(chart_ID, name, OBJ_TREND, sub_window, time1, price1, time2, price2))
{
Print(__FUNCTION__,
": ¡Fallo al crear la línea de tendencia! Código del error = ", GetLastError());
return(false);
}
//--- establecemos el color de la línea
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
ObjectSetString(chart_ID, name, OBJPROP_TOOLTIP, tooltip);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::TrendaAngleCreate(long chart_ID, // ID del gráfico
const string& name, // Nombre de la línea
int sub_window, // índice de subventana
datetime time1, // hora del primer punto
double price1, // precio del primer punto
datetime time2, // hora del segundo punto
double price2, // precio del segundo punto
color clr, // color de la línea
ENUM_LINE_STYLE style, // estilo de la línea
int width, // grosor de la línea
bool back, // al fondo
bool selection, // seleccionar para mover
const string& tooltip
)
{
//--- establecemos las coordenadas de los puntos de anclaje si todavía no han sido establecidas
//--- anulamos el valor del error
ResetLastError();
//--- creamos la línea de tendencia según las coordenadas establecidas
if(!ObjectCreate(chart_ID, name, OBJ_TRENDBYANGLE, sub_window, time1, price1, time2, price2))
{
Print(__FUNCTION__,
": ¡Fallo al crear la línea de tendencia! Código del error = ", GetLastError());
return(false);
}
//--- establecemos el color de la línea
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
ObjectSetString(chart_ID, name, OBJPROP_TOOLTIP, tooltip);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::TextCreate(long chart_ID, // ID del gráfico
const string& name, // nombre del objeto
int sub_window, // número de subventana
datetime time, // hora del punto de anclaje
double price, // precio del punto de anclaje
const string& text, // el texto
const string& font, // fuente
int font_size, // tamaño de la fuente
color clr, // color
double angle, // inclinación del texto
ENUM_ANCHOR_POINT anchor, // modo de anclaje
bool back, // al fondo
bool selection) // seleccionar para mover
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos el objeto "Texto"
if(!ObjectCreate(chart_ID, name, OBJ_TEXT, sub_window, time, price))
{
PrintFormat("Fallo al crear el texto %s, ultimo error %i", name, GetLastError());
return(false);
}
//--- ponemos el texto
ObjectSetString(chart_ID, name, OBJPROP_TEXT, text);
ObjectSetString(chart_ID, name, OBJPROP_TOOLTIP, text);
//--- establecemos la fuente del texto
ObjectSetString(chart_ID, name, OBJPROP_FONT, font);
//--- establecemos el tamaño del texto
ObjectSetInteger(chart_ID, name, OBJPROP_FONTSIZE, font_size);
//--- establecemos el ángulo de inclinación del texto
ObjectSetDouble(chart_ID, name, OBJPROP_ANGLE, angle);
//--- establecemos el modo de anclaje
ObjectSetInteger(chart_ID, name, OBJPROP_ANCHOR, anchor);
//--- establecemos el color
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de desplazamiento del texto con ratón
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//ChartRedraw(chart_ID);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::ArrowCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre de la flecha
const int sub_window, // número de subventana
datetime time, // hora del punto de anclaje
double price, // precio del punto de anclaje
const uchar arrow_code, // código de la flecha
const ENUM_ARROW_ANCHOR anchor, // posición del punto de anclaje
const color clr, // color de la flecha
const ENUM_LINE_STYLE style, // estilo de la línea del contorno
const int width, // tamaño de la flecha
const bool back, // al fondo
const bool selection, // seleccionar para mover
const long z_order) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos la flecha
if(!ObjectCreate(chart_ID, name, OBJ_ARROW, sub_window, time, price))
{
Print(__FUNCTION__,
": ¡Fallo al crear la flecha! Código del error = ", GetLastError(), " el nombre: ", name);
return(false);
}
//--- establecemos el código de la flecha
ObjectSetInteger(chart_ID, name, OBJPROP_ARROWCODE, arrow_code);
//--- establecemos el modo de anclaje
ObjectSetInteger(chart_ID, name, OBJPROP_ANCHOR, anchor);
//--- establecemos el color de la flecha
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el estilo de la línea del contorno
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
//--- establecemos el tamaño de la flecha
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de desplazamiento de la flecha con ratón
//--- cuando el objeto gráfico se crea usando la función ObjectCreate, por defecto el objeto
//--- no se puede seleccionar y mover. Mientras que dentro de este método el parámetro selection
//--- por defecto es igual a true, lo que permite seleccionar y mover este objeto
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- establecemos la prioridad para obtener el evento de cliquear sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::EditCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre del objeto
const int sub_window, // número de subventana
const int x, // coordenada por el eje X
const int y, // coordenada por el eje Y
const int width, // ancho
const int height, // alto
const string& text, // texto
const string& font, // fuente
const int font_size, // tamaño de la fuente
const ENUM_ALIGN_MODE align, // modo de alineación
const bool read_only, // posibilidad de edición
const ENUM_BASE_CORNER corner, // esquina del gráfico para el enlace
const color clr, // color del texto
const color back_clr, // color del fondo
const color border_clr, // color del borde
const bool back, // al fondo
const bool selection, // seleccionar para mover
const bool hidden, // ocultar en la lista de objetos
const long z_order) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos el campo de edición
if(!ObjectCreate(chart_ID, name, OBJ_EDIT, sub_window, 0, 0))
{
Print(__FUNCTION__,
": ¡Fallo al crear el objeto \"Campo de edición\"! Código del error = ", GetLastError());
return(false);
}
//--- establecemos las coordenadas del objeto
ObjectSetInteger(chart_ID, name, OBJPROP_XDISTANCE, x);
ObjectSetInteger(chart_ID, name, OBJPROP_YDISTANCE, y);
//--- establecemos el tamaño del objeto
ObjectSetInteger(chart_ID, name, OBJPROP_XSIZE, width);
ObjectSetInteger(chart_ID, name, OBJPROP_YSIZE, height);
//--- ponemos el texto
ObjectSetString(chart_ID, name, OBJPROP_TEXT, text);
//--- establecemos la fuente del texto
ObjectSetString(chart_ID, name, OBJPROP_FONT, font);
//--- establecemos el tamaño del texto
ObjectSetInteger(chart_ID, name, OBJPROP_FONTSIZE, font_size);
//--- establecemos el modo de alineación del texto dentro del objeto
ObjectSetInteger(chart_ID, name, OBJPROP_ALIGN, align);
//--- ponemos (true) o cancelamos (false) el modo sólo para lectura
ObjectSetInteger(chart_ID, name, OBJPROP_READONLY, read_only);
//--- establecemos la esquina del gráfico respecto a la cual van a determinarse las coordenadas del objeto
ObjectSetInteger(chart_ID, name, OBJPROP_CORNER, corner);
//--- establecemos el color del texto
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el color del fondo
ObjectSetInteger(chart_ID, name, OBJPROP_BGCOLOR, back_clr);
//--- establecemos el color del borde
ObjectSetInteger(chart_ID, name, OBJPROP_BORDER_COLOR, border_clr);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de desplazamiento de la etiqueta con ratón
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- ocultamos (true) o mostramos (false) el nombre del objeto gráfico en la lista de objetos
ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, hidden);
//--- establecemos la prioridad para obtener el evento de cliquear sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::ButtonCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre del botón
const int sub_window, // número de subventana
const int x, // coordenada por el eje X
const int y, // coordenada por el eje Y
const int width, // ancho del botón
const int height, // alto del botón
const ENUM_BASE_CORNER corner, // esquina del gráfico para el enlace
const string& text, // texto
const string& font, // fuente
const int font_size, // tamaño de la fuente
const color clr, // color del texto
const color back_clr, // color del fondo
const color border_clr, // color del borde
const bool state, // pulsado/no pulsado
const bool back, // al fondo
const bool selection, // seleccionar para mover
const bool hidden, // ocultar en la lista de objetos
const long z_order) //prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos el botón
if(!ObjectCreate(chart_ID, name, OBJ_BUTTON, sub_window, 0, 0))
{
Print(__FUNCTION__,
": ¡Fallo al crear el botón! Código del error = ", GetLastError());
return(false);
}
//--- establecemos las coordenadas del botón
ObjectSetInteger(chart_ID, name, OBJPROP_XDISTANCE, x);
ObjectSetInteger(chart_ID, name, OBJPROP_YDISTANCE, y);
//--- establecemos el tamaño del botón
ObjectSetInteger(chart_ID, name, OBJPROP_XSIZE, width);
ObjectSetInteger(chart_ID, name, OBJPROP_YSIZE, height);
//--- establecemos la esquina del gráfico respecto a la cual van a determinarse las coordenadas del punto
ObjectSetInteger(chart_ID, name, OBJPROP_CORNER, corner);
//--- ponemos el texto
ObjectSetString(chart_ID, name, OBJPROP_TEXT, text);
//--- establecemos la fuente del texto
ObjectSetString(chart_ID, name, OBJPROP_FONT, font);
//--- establecemos el tamaño del texto
ObjectSetInteger(chart_ID, name, OBJPROP_FONTSIZE, font_size);
//--- establecemos el color del texto
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el color del fondo
ObjectSetInteger(chart_ID, name, OBJPROP_BGCOLOR, back_clr);
//--- establecemos el color del borde
ObjectSetInteger(chart_ID, name, OBJPROP_BORDER_COLOR, border_clr);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- set button state
ObjectSetInteger(chart_ID, name, OBJPROP_STATE, state);
//--- activar (true) o desactivar (false) el modo de desplazamiento del botón con ratón
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- ocultamos (true) o mostramos (false) el nombre del objeto gráfico en la lista de objetos
ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, hidden);
//--- establecemos la prioridad para obtener el evento de cliquear sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::RectLabelCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre de la etiqueta
const int sub_window, // número de subventana
const int x, // coordenada por el eje X
const int y, // coordenada por el eje Y
const int width, // ancho
const int height, // alto
const color back_clr, // color del fondo
const ENUM_BORDER_TYPE border, // tipo del borde
const ENUM_BASE_CORNER corner, // esquina del gráfico para el enlace
const color clr, // color del contorno plano (Flat)
const ENUM_LINE_STYLE style, // estilo del contorno plano
const int line_width, // grosor del contorno plano
const bool back, // al fondo
const bool selection, // seleccionar para mover
const bool hidden, // ocultar en la lista de objetos
const long z_order) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos la etiqueta rectangular
if(!ObjectCreate(chart_ID, name, OBJ_RECTANGLE_LABEL, sub_window, 0, 0))
{
Print(__FUNCTION__,
": ¡Fallo al crear la etiqueta rectangular! Código del error = ", GetLastError());
return(false);
}
//--- establecemos las coordenadas de la etiqueta
ObjectSetInteger(chart_ID, name, OBJPROP_XDISTANCE, x);
ObjectSetInteger(chart_ID, name, OBJPROP_YDISTANCE, y);
//--- establecemos las dimensiones de la etiqueta
ObjectSetInteger(chart_ID, name, OBJPROP_XSIZE, width);
ObjectSetInteger(chart_ID, name, OBJPROP_YSIZE, height);
//--- establecemos el color del fondo
ObjectSetInteger(chart_ID, name, OBJPROP_BGCOLOR, back_clr);
//--- establecemos el tipo del borde
ObjectSetInteger(chart_ID, name, OBJPROP_BORDER_TYPE, border);
//--- establecemos la esquina del gráfico respecto a la cual van a determinarse las coordenadas del punto
ObjectSetInteger(chart_ID, name, OBJPROP_CORNER, corner);
//--- establecemos el color del contorno plano (en modo Flat)
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el estilo de las líneas del contorno plano
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
//--- establecemos el grosor del contorno plano
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, line_width);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de desplazamiento de la etiqueta con ratón
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- ocultamos (true) o mostramos (false) el nombre del objeto gráfico en la lista de objetos
ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, hidden);
//--- establecemos la prioridad para obtener el evento de cliquear sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::ArrowRightPriceCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre de la etiqueta de precio
const int sub_window, // número de subventana
datetime time, // hora del punto de anclaje
double price, // precio del punto de anclaje
const color clr, // color de la etiqueta de precio
const ENUM_LINE_STYLE style, // estilo de la línea del contorno
const int width, // tamaño de la etiqueta de precio
const bool back, // al fondo
const bool selection, // seleccionar para mover
const bool hidden, // ocultar en la lista de objetos
const long z_order) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos la etiqueta de precio
if(!ObjectCreate(chart_ID, name, OBJ_ARROW_RIGHT_PRICE, sub_window, time, price))
{
Print(__FUNCTION__,
": ¡Fallo al crear la etiqueta derecha de precio! Código del error = ", GetLastError());
return(false);
}
//--- establecemos el color de la etiqueta
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el estilo de la línea del contorno
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
//--- establecemos el tamaño de la etiqueta
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de desplazamiento de la etiqueta con ratón
//--- cuando el objeto gráfico se crea usando la función ObjectCreate, por defecto el objeto
//--- no se puede seleccionar y mover. Mientras que dentro de este método el parámetro selection
//--- por defecto es igual a true, lo que permite seleccionar y mover este objeto
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- ocultamos (true) o mostramos (false) el nombre del objeto gráfico en la lista de objetos
ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, hidden);
//--- establecemos la prioridad para obtener el evento de cliquear sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::EventCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre del evento
const int sub_window, // número de subventana
const string& text, // texto del evento
datetime time, // hora
const color clr, // color
const int width, // grosor del punto durante la selección
const bool back, // al fondo
const string& tooltip,
const bool selection, // seleccionar para mover
const long z_order) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos el objeto "Evento"
if(!ObjectCreate(chart_ID, name, OBJ_EVENT, sub_window, time, 0))
{
Print(__FUNCTION__,
": ¡Fallo al crear el objeto \"Evento\"! Código del error = ", GetLastError());
return(false);
}
//--- ponemos el texto del evento
ObjectSetString(chart_ID, name, OBJPROP_TEXT, text);
//--- establecemos el color
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el grosor del punto de anclaje si el objeto está seleccionado
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de desplazamiento del evento con ratón
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- ocultamos (true) o mostramos (false) el nombre del objeto gráfico en la lista de objetos
ObjectSetString(chart_ID, name, OBJPROP_TOOLTIP, tooltip);
//--- establecemos la prioridad para obtener el evento de cliquear sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::RectangleCreate(long chart_ID,
const string& name,
const int sub_window,
datetime time1,
double price1,
datetime time2,
double price2,
color clr,
int width,
bool fill,
bool back,
bool select,
ENUM_LINE_STYLE style,
const string& tooltip
)
{
ResetLastError();
// Crear objeto
if(!ObjectCreate(chart_ID, name, OBJ_RECTANGLE, sub_window, time1, price1, time2, price2))
{
Print(__FUNCTION__, ": Failed to create rectangle! Error code = ", GetLastError(), " name: ", name);
return false;
}
// Seteo de propiedades
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
ObjectSetInteger(chart_ID, name, OBJPROP_FILL, fill);
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, select);
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
ObjectSetString(chart_ID, name, OBJPROP_TOOLTIP, tooltip);
return true;
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::FiboLevelsCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre del objeto
const int sub_window, // número de subventana
datetime time1, // hora del primer punto
double price1, // precio del primer punto
datetime time2, // hora del segundo punto
double price2, // precio del segundo punto
const color clr, // color del objeto
const ENUM_LINE_STYLE style, // estilo de las líneas del objeto
const int width, // grosor de las líneas del objeto
const bool back, // al fondo
const bool selection, // seleccionar para mover
const bool ray_left, // continuación del objeto a la izquierda
const bool ray_right, // continuación del objeto a la derecha
const long z_order) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos los "Retrocesos de Fibonacci" según las coordenadas establecidas
if(!ObjectCreate(chart_ID, name, OBJ_FIBO, sub_window, time1, price1, time2, price2))
{
Print(__FUNCTION__,
": ¡Falo al crear los \"Retrocesos de Fibonacci\"! Código del error = ", GetLastError());
return(false);
}
//--- establecemos el color
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el estilo de la línea
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
//--- establecemos el grosor de la línea
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de selección del objeto para mover
//--- cuando el objeto gráfico se crea usando la función ObjectCreate, por defecto el objeto
//--- no se puede seleccionar y mover. Mientras que dentro de este método el parámetro selection
//--- por defecto es igual a true, lo que permite seleccionar y mover este objeto
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
//--- activamos (true) o desactivamos (false) el modo de continuación del objeto a la izquierda
ObjectSetInteger(chart_ID, name, OBJPROP_RAY_LEFT, ray_left);
//--- activamos (true) o desactivamos (false) el modo de continuación del objeto a la derecha
ObjectSetInteger(chart_ID, name, OBJPROP_RAY_RIGHT, ray_right);
//--- establecemos la prioridad para obtener el evento de cliquear con el ratón sobre el gráfico
ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::FiboLevelsSet(int levels, // número de las líneas del nivel
double &values[], // valores de las líneas del nivel
color &colors[], // color de las líneas del nivel
ENUM_LINE_STYLE &styles[], // estilo de las líneas del nivel
int &widths[], // grosor de las líneas del nivel
const long chart_ID, // ID del gráfico
const string& name) // nombre del objeto
{
//--- comprobamos los tamaños de los arrays
if(levels != ArraySize(colors) || levels != ArraySize(styles) || levels != ArraySize(widths))
{
Print(__FUNCTION__, ": ¡Error. La longitud del array no corresponde al número de los niveles!");
return(false);
}
//--- establecemos el número de los niveles
ObjectSetInteger(chart_ID, name, OBJPROP_LEVELS, levels);
//--- establecemos las propiedades de los niveles en el ciclo
for(int i = 0; i < levels; i++)
{
//--- valor del nivel
ObjectSetDouble(chart_ID, name, OBJPROP_LEVELVALUE, i, values[i]);
//--- color del nivel
ObjectSetInteger(chart_ID, name, OBJPROP_LEVELCOLOR, i, colors[i]);
//--- estilo del nivel
ObjectSetInteger(chart_ID, name, OBJPROP_LEVELSTYLE, i, styles[i]);
//--- grosor del nivel
ObjectSetInteger(chart_ID, name, OBJPROP_LEVELWIDTH, i, widths[i]);
//--- descripción del nivel
ObjectSetString(chart_ID, name, OBJPROP_LEVELTEXT, i, DoubleToString(100 * values[i], 1));
}
//--- ejecución con éxito
return(true);
}
//+------------------------------------------------------------------+
bool CNativeoGObjs::ChannelCreate(const long chart_ID, // ID del gráfico
const string& name, // nombre del canal
const int sub_window, // número de subventana
datetime time1, // hora del primer punto
double price1, // precio del primer punto
datetime time2, // hora del segundo punto
double price2, // precio del segundo punto
datetime time3, // hora del tercer punto
double price3, // precio del tercer punto
const color clr, // color del canal
const ENUM_LINE_STYLE style, // estilo de las líneas del canal
const int width, // grosor de las líneas del canal
const bool fill, // relleno del canal con el color
const bool back, // al fondo
const bool selection, // seleccionar para mover
const string& tooltip
) // prioridad para el clic del ratón
{
//--- anulamos el valor del error
ResetLastError();
//--- creamos el canal según las coordenadas establecidas
if(!ObjectCreate(chart_ID, name, OBJ_CHANNEL, sub_window, time1, price1, time2, price2, time3, price3))
{
Print(__FUNCTION__,
": ¡Fallo al crear el canal equidistante! Código del error = ", GetLastError());
return(false);
}
//--- fijamos el color del canal
ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
//--- establecemos el estilo de las líneas del canal
ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style);
//--- establecemos el grosor de las líneas del canal
ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, width);
//--- activar (true) o desactivar (false) el modo de relleno del canal
ObjectSetInteger(chart_ID, name, OBJPROP_FILL, fill);
//--- mostramos en el primer plano (false) o al fondo (true)
ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
//--- activar (true) o desactivar (false) el modo de selección del canal para mover
//--- cuando el objeto gráfico se crea usando la función ObjectCreate, por defecto el objeto
//--- no se puede seleccionar y mover. Mientras que dentro de este método el parámetro selection
//--- por defecto es igual a true, lo que permite seleccionar y mover este objeto
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
ObjectSetString(chart_ID, name, OBJPROP_TOOLTIP, tooltip);
//--- ejecución con éxito
return(true);
}
//---
}
#endif // MQLARTICLES_UTILS_OBJECTS_NATIVE_IMP_MQH
//+------------------------------------------------------------------+