ForkGrapichsByLeo/Tests/Distribucion.mq5

75 lines
4.6 KiB
MQL5
Raw Permalink Normal View History

2025-11-17 17:02:53 -05:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| NormalDistribution.mq5 |
//| Copyright 2025, Test Example |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Test Example"
#property strict
#include "..\\Histogram\\Main.mqh"
2025-11-28 07:55:33 -05:00
// https://forge.mql5.io/amrali/Xoshiro256
#include "..\\..\\Xoshiro256\\Xoshiro256.mqh"
2025-11-17 17:02:53 -05:00
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
2025-11-28 07:55:33 -05:00
{
//---
#define DATA_SIZE 5000
#define BINS 30
2026-01-13 17:15:57 -05:00
//---
CCanvasCustom canvas;
canvas.CreateBitmapLabel("HolaXd", 0, 0, 800, 600, COLOR_FORMAT_ARGB_RAW);
canvas.Erase(ColorToARGB(clrAquamarine));
2025-11-28 07:55:33 -05:00
//--- Crear histograma
CHistogramVertical histograma;
2026-01-13 17:15:57 -05:00
histograma.Initialize(&canvas, 20, 20, 600, 520, ColorToARGB(clrWhite));
//histograma.CreateBitmapLabel(50, 50, COLOR_FORMAT_ARGB_RAW);
2025-11-28 07:55:33 -05:00
//--- T<EFBFBD>tulo y copyright
histograma.TituloDefault(StringFormat("Distribucion Normal - %d Barras", BINS));
histograma.CreateCopyrightDefault("Test");
//--- Generar datos
Xoshiro256 random;
double datos_normales[DATA_SIZE];
for(int i = 0; i < DATA_SIZE; i++)
{
datos_normales[i] = random.RandomNormal();
}
//--- Crear UN SOLO conjunto con bins autom<EFBFBD>ticos
uint clr_barras = ColorToARGB(clrSteelBlue);
histograma.AddConjuntoBarWithBinsDeft("Normal", datos_normales, BINS, clr_barras);
//--- Inicializar lienzo (sin corte)
int x1 = 70;
int y1 = 50;
2026-01-13 17:15:57 -05:00
int x2 = 550;
int y2 = 450;
2025-11-28 07:55:33 -05:00
histograma.InitLienzoBarras(x1, y1, x2, y2, 10, 10, 3);
//--- Ejes (cambian para vertical)
2025-12-05 07:06:30 -05:00
histograma.CreateBordesEjesGridsSimple(HIST_LINE_MODE_ABAJO);
2025-11-28 07:55:33 -05:00
histograma.EjeLineGetPointer().HistogramLinePointerGet().CreateTitulo("Frecuencia", ColorToARGB(clrBlack), 25, 12, "Arial");
//--- Redibujar
histograma.Redraw();
//--- Guardar imagen
histograma.SavePicture("distribucion_normal_vertical.png", true);
//--- Esperar
while(!IsStopped())
{
Sleep(1000);
}
2026-01-13 17:15:57 -05:00
//---
canvas.Destroy();
2025-11-28 07:55:33 -05:00
}
//+------------------------------------------------------------------+