| //+------------------------------------------------------------------+
|
| //| Defines.mqh |
|
| //| Copyright 2025, Niquel Mendoza. |
|
| //| https://www.mql5.com/es/users/nique_372/news |
|
| //+------------------------------------------------------------------+
|
| #property copyright "Copyright 2025, Niquel Mendoza."
|
| #property link "https://www.mql5.com/es/users/nique_372/news"
|
| #property strict
|
|
|
| #ifndef HISTOGRAM_BARRA_DEFINES_BY_LEO_MQH
|
| #define HISTOGRAM_BARRA_DEFINES_BY_LEO_MQH
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| #include "..\\..\\General\\Canvas.mqh"
|
| #include "..\\..\\..\\MQLArticles\\Utils\\Basic.mqh"
|
|
|
| //+------------------------------------------------------------------+
|
| //| Tipo de histograma |
|
| //+------------------------------------------------------------------+
|
| enum ENUM_HISTOGAM_TYPE
|
| {
|
| HISTOGRAM_HORIZONTAL = 0,
|
| HISTOGRAM_VERTICAL = 1
|
| };
|
|
|
|
|
|
|
| //+------------------------------------------------------------------+
|
| //| Calculo de la posicion del texto |
|
| //+------------------------------------------------------------------+
|
| typedef void(*HistogramFuncionCalculateText)(int x1, int y1, int x2, int y2, int& xtext, int& ytext);
|
|
|
|
|
| //+------------------------------------------------------------------+
|
| //| Conversion de valor a pixel |
|
| //+------------------------------------------------------------------+
|
| typedef int(*HistogramFuncionCalculatePixel)(const double& value, const double& value_corte, const double& factor_pos, const double& factor_neg);
|
|
|
| namespace HistogramFunctions
|
| {
|
| //+------------------------------------------------------------------+
|
| __forceinline int ValueToPixelComplete(const double& value, const double& value_corte, const double& factor_pos, const double& factor_neg)
|
| {
|
| return int((value - value_corte) * factor_pos); // se usa el positivo OJO
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| __forceinline int ValueToPixelCorte(const double& value, const double& value_corte, const double& factor_pos, const double& factor_neg)
|
| {
|
| // Si es mayor a factor_pos retornanra un valor posiitivo de lo contrairo negativo
|
| return int((value - value_corte) * (value >= value_corte ? factor_pos : factor_neg));
|
| }
|
| }
|
|
|
| /*
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| typedef bool(*CHistogramConjuntoFuncSort)(MqlParam ¶ms[], double value1, double value2);
|
| namespace HistogramFuncionCompare
|
| {
|
| __forceinline bool HistValueIsMayor(MqlParam ¶ms[], double value1, double value2)
|
| {
|
| return value1 > value2;
|
| }
|
| }*/
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| typedef void(*HistFunctionDrawRect)(CCanvasCustom* canvas, int x1, int y1, int x2, int y2, uint clr);
|
|
|
| namespace HistConjuntoDrawRectFunctions
|
| {
|
| __forceinline void HistDrawRectFill(CCanvasCustom* canvas, int x1, int y1, int x2, int y2, uint clr)
|
| {
|
| canvas.FillRectangle(x1, y1, x2, y2, clr);
|
| }
|
| __forceinline void HistDrawRectNoFill(CCanvasCustom* canvas, int x1, int y1, int x2, int y2, uint clr)
|
| {
|
| canvas.Rectangle(x1, y1, x2, y2, clr);
|
| }
|
| }
|
|
|
| enum ENUM_HIST_DRAW_RECT_STYLE
|
| {
|
| HIST_DRAW_RECT_NO_FILL = 0,
|
| HIST_DRAW_RECT_FILL = 1
|
| };
|
|
|
| //+------------------------------------------------------------------+
|
| //| Macros |
|
| //+------------------------------------------------------------------+
|
| // Calculo del ancho unico (tamaño de barra unico total) - (total_iicl se le resta los espacois) / numero d ebarras
|
| #define HISTOGRAM_CONJ_RECALCULE m_barras_ancho_unico = (m_barras_ancho_total - (m_barras_size - 1)) / m_barras_size;
|
|
|
| // Caclulo de valor a pixel
|
| #define HISTOGRAM_CONJ_VALUE_TO_PIXEL(value) m_function_calc_pixel(value, m_fcort, m_fpos, m_fneg)
|
|
|
| //--- Activar el autoresize del fontsize para los conjuntos
|
| #define HISTOGRAM_CONJ_ACTIVAR_AUTO_RESIZE
|
|
|
| //+------------------------------------------------------------------+
|
| //| Estrcutra base para una barra de histograma |
|
| //+------------------------------------------------------------------+
|
| struct HistogramBar
|
| {
|
| double value;
|
| int x1;
|
| int y1;
|
| int x2;
|
| int y2;
|
| uint clr;
|
|
|
| //---
|
| HistogramBar()
|
| : x1(0), x2(0), y1(0), y2(0), value(0.00), clr(clrBlack)
|
| {
|
|
|
| }
|
|
|
| HistogramBar(int _x1, int _y1, int _x2, int _y2, double v, uint c)
|
| : x1(_x1), x2(_x2), y1(_y1), y2(_y2), value(v), clr(c)
|
| {
|
|
|
| }
|
| };
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| //--- Titulo
|
| /*
|
| struct HistogramTituloLabel
|
| {
|
| string value;
|
| string font;
|
| int x;
|
| int y;
|
| uint clr;
|
| int font_size;
|
| ENUM_HISTOGRAM_TITULO_POSICION position;
|
| uint alingement;
|
| int height;
|
| };*/
|
| //+------------------------------------------------------------------+
|
| #endif |