forked from nique_372/GrapichsByLeo
//+------------------------------------------------------------------+
| |
//| 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
| |
| |
//--- Crear histograma
| |
CHistogramVertical histograma;
| |
histograma.Initialize(800, 600, "HistogramaNormal", 0, 0, 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 = 700;
| |
int y2 = 500;
| |
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);
| |
}
| |
}
| |
//+------------------------------------------------------------------+
|