forked from nique_372/GrapichsByLeo
//+------------------------------------------------------------------+
| |
//| Test.mq5 |
| |
//| 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 version "1.00"
| |
#property strict
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#include "..\\Histogram\\Main.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| Script program start function |
| |
//+------------------------------------------------------------------+
| |
void OnStart()
| |
{
| |
//---
| |
CHistogramHorizontal his_horizontal;
| |
his_horizontal.Initialize(600, 500, "HistogramaLabel", 0, 0, ColorToARGB(clrWhite));
| |
his_horizontal.MinPxToUpdate(0);
| |
his_horizontal.CreateBitmapLabel(100, 0, COLOR_FORMAT_ARGB_RAW);
| |
| |
//---
| |
int width_parte_inf = 100;
| |
| |
//---
| |
uint clr_p1 = 0xFF87ACCB;
| |
uint clr_p2 = 0xFFC2A0AA;
| |
uint clr_p3 = 0xFFD2A06A;
| |
uint clr_black = ColorToARGB(clrBlack);
| |
| |
//--- Paso 1 titulo
| |
int xgap = 20;
| |
int ygap = 30;
| |
| |
his_horizontal.TituloDefault("Test titulo");
| |
CHistogramTitulo* titulo_ptr = his_horizontal.TituloGetPointer();
| |
// titulo_ptr.Text("Texto nuevo");
| |
| |
//--- Paso 1.5 Copyright (Opcional)
| |
his_horizontal.CreateCopyrightDefault("Leo");
| |
| |
//--- Paso 2: Agregar conjunto de barras
| |
his_horizontal.AddConjuntoBar("Grupo 1", 8, "Arial", HISTOGRAM_TEXT_MODE_CENTER, 3, 10, HIST_DRAW_RECT_FILL, 0.20);
| |
his_horizontal.AddBarToConjuntoBarFast(10.0, clr_p1);
| |
his_horizontal.AddBarToConjuntoBarFast(12.0, clr_p2);
| |
his_horizontal.AddBarToConjuntoBarFast(15.0, clr_p3);
| |
| |
his_horizontal.AddConjuntoBar("Grupo 2", 8, "Arial", HISTOGRAM_TEXT_MODE_CENTER, 3, 10, HIST_DRAW_RECT_FILL, 0.20);
| |
his_horizontal.AddBarToConjuntoBarFast(12.0, clr_p1);
| |
his_horizontal.AddBarToConjuntoBarFast(20.0, clr_p2);
| |
his_horizontal.AddBarToConjuntoBarFast(25.0, clr_p3);
| |
| |
his_horizontal.AddConjuntoBar("Grupo 3", 8, "Arial", HISTOGRAM_TEXT_MODE_CENTER, 3, 10, HIST_DRAW_RECT_FILL, 0.60);
| |
his_horizontal.AddBarToConjuntoBarFast(7.0, clr_p1);
| |
his_horizontal.AddBarToConjuntoBarFast(28.0, clr_p2);
| |
his_horizontal.AddBarToConjuntoBarFast(22.0, clr_p3);
| |
| |
//--- Paso 3 Inicilizaicon
| |
int x1 = xgap + 50;
| |
int x2 = 600 - 200;
| |
int y1 = ygap;
| |
int y2 = 500 - ygap - 25;
| |
| |
his_horizontal.InitLienzoBarras(x1, y1, x2, y2, 5, 5, 5);
| |
//his_horizontal.GetLineCortePtr().Color(ColorToARGB(clrLightSteelBlue));
| |
| |
//--- Paso 4 Parte informativa (Opcional)
| |
his_horizontal.CreatePartInformativa(HISTOGRAM_PARTE_INF_DERECHA, 10, 10);
| |
CHistogramParteInfo* info = his_horizontal.GetPartInfPointer();
| |
| |
if(CheckPointer(info) == POINTER_DYNAMIC)
| |
{
| |
info.AddText("LEYENDA", clr_black, 20, 0, "Arial", 10, false);
| |
info.AddLegend("P1", clr_black, 0xFF87ACCB, clr_black,
| |
5, 15, 15, 20, 0, "Arial", 8, false);
| |
info.AddLegend("P2", clr_black, 0xFFD2A06A, clr_black,
| |
5, 15, 15, 20, 0, "Arial", 8, false);
| |
info.AddLegend("P3", clr_black, 0xFFB8956A, clr_black,
| |
5, 15, 15, 20, 0, "Arial", 8, false);
| |
info.AddText("Prueba para la aprte informativa", clr_black, 10, 0);
| |
}
| |
| |
//--- Paso 5 Ejes (Opcional)
| |
his_horizontal.CreateBordesEjesGridsSimple(HIST_LINE_MODE_IZQUIERDA);
| |
his_horizontal.EjeLineGetPointer().HistogramLinePointerGet().CreateTitulo("Prueba de valores", clr_black, 25, 12, "Arial"); // Creamos el titulo de las secciones
| |
his_horizontal.EjeLineGetPointer().CreateTituloEje2(25, "Grupos", clr_black, 13, "Arial");
| |
| |
//---
| |
his_horizontal.Redraw();
| |
Sleep(5000);
| |
| |
//--
| |
int c = 0;
| |
MathSrand(65160);
| |
CColorGeneratorArgb* ptr_gen = his_horizontal.GetColorGeneratorPointer();
| |
| |
while(c++ < 30)
| |
{
| |
int rand_index = rand() % 3;
| |
his_horizontal.ReadIndex(rand_index);
| |
int rnad_index_conjunto = rand() % his_horizontal.SizeBarsOfConjunto();
| |
his_horizontal.BarColor(rnad_index_conjunto, ptr_gen.Next(), false);
| |
double nuevo_valor = 1.0 + (MathRand() % 300) / 5.0; // Rango: 5.0 - 35.0
| |
his_horizontal.BarValue(rnad_index_conjunto, nuevo_valor, false);
| |
his_horizontal.RedrawGrid();
| |
his_horizontal.Redraw();
| |
Sleep(2000);
| |
}
| |
| |
//---
| |
his_horizontal.SavePicture("histogram_1.png", true);
| |
while(!IsStopped())
| |
{
| |
Sleep(2000);
| |
}
| |
}
| |
//+------------------------------------------------------------------+
|