2026-09-01 10:06:29 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| NormalDistribution.mq5 |
|
| | | //| Copyright 2025, Test Example |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2025, Test Example"
|
| | | #property strict
|
| | |
|
| | | #include "..\\Histogram\\Main.mqh"
|
| | | #include <TSN\\Random\\AllPRNG.mqh>
|
| | | #include <TSN\\Random\\Base.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
|
| | | TSN::CRandom<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();
|
| | | }
|
| | | //+------------------------------------------------------------------+
|