Crear Gráfico de Cotizaciones Altas Bajas Cierre (HLC)

Escenarios de uso posibles

El gráfico de cotizaciones altas-bajas-cierre (HLC) utiliza cuatro columnas de datos. La primera columna es una categoría, usualmente una fecha pero también se pueden usar nombres de acciones. Las siguientes tres columnas en orden son para los precios altos, bajos y de cierre. El rango de precio para cada categoría se indica mediante una línea vertical de bajo a alto, y el precio de cierre se muestra usando una marca extendiéndose hacia la derecha de esta línea.

todo:image_alt_text

Mejoras de visibilidad en el gráfico

A veces, para que el gráfico luzca más intuitivo, podemos modificar la apariencia del marcador (cierre), o hacer que se muestre en el eje secundario.

todo:image_alt_text

Código de muestra

El siguiente código de ejemplo carga el archivo de Excel de muestra y genera el archivo de Excel de salida.

// Create an instance of Workbook
Workbook workbook = new Workbook("High-Low-Close.xlsx");
// Access the first worksheet.
Worksheet worksheet = workbook.Worksheets[0];
//Create High-Low-Close-Stock Chart
int pieIdx = worksheet.Charts.Add(ChartType.StockHighLowClose, 5, 6, 20, 12);
// Retrieve the Chart object
Chart chart = worksheet.Charts[pieIdx];
// Set the legend can be showed
chart.ShowLegend = true;
// Set the chart title name
chart.Title.Text = "High-Low-Close Stock";
// Set the Legend at the bottom of the chart area
chart.Legend.Position = LegendPositionType.Bottom;
// Set data range
chart.SetChartDataRange("A1:D9", true);
// Set category data
chart.NSeries.CategoryData = "A2:A9";
// Set the marker with the built-in data
chart.NSeries[2].Marker.MarkerStyle = ChartMarkerType.Dash;
chart.NSeries[2].Marker.MarkerSize = 20;
chart.NSeries[2].Marker.Area.Formatting = FormattingType.Custom;
chart.NSeries[2].Marker.Area.ForegroundColor = Color.Maroon;
// Fill the PlotArea area with nothing
chart.PlotArea.Area.FillFormat.FillType = FillType.None;
// Save the Excel file
workbook.Save("out.xlsx");