1
0
Fourche 0
bifurqué depuis nique_372/GrapichsByLeo
ForkGrapichsByLeo/Tests/Distribucion.mq5
nique_372 420cfbc31d
2026-01-13 17:15:57 -05:00

74 lignes
4,6 Kio
MQL5

//+------------------------------------------------------------------+
//| NormalDistribution.mq5 |
//| Copyright 2025, Test Example |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Test Example"
#property strict
#include "..\\Histogram\\Main.mqh"
// https://forge.mql5.io/amrali/Xoshiro256
#include "..\\..\\Xoshiro256\\Xoshiro256.mqh"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
#define DATA_SIZE 5000
#define BINS 30
//---
CCanvasCustom canvas;
canvas.CreateBitmapLabel("HolaXd", 0, 0, 800, 600, COLOR_FORMAT_ARGB_RAW);
canvas.Erase(ColorToARGB(clrAquamarine));
//--- Crear histograma
CHistogramVertical histograma;
histograma.Initialize(&canvas, 20, 20, 600, 520, ColorToARGB(clrWhite));
//histograma.CreateBitmapLabel(50, 50, COLOR_FORMAT_ARGB_RAW);
//--- Tí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áticos
uint clr_barras = ColorToARGB(clrSteelBlue);
histograma.AddConjuntoBarWithBinsDeft("Normal", datos_normales, BINS, clr_barras);
//--- Inicializar lienzo (sin corte)
int x1 = 70;
int y1 = 50;
int x2 = 550;
int y2 = 450;
histograma.InitLienzoBarras(x1, y1, x2, y2, 10, 10, 3);
//--- Ejes (cambian para vertical)
histograma.CreateBordesEjesGridsSimple(HIST_LINE_MODE_ABAJO);
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);
}
//---
canvas.Destroy();
}
//+------------------------------------------------------------------+