Crea un grafico di scorta Open High Low Close (OHLC)

Possibili Scenari di Utilizzo

Il grafico Open-High-Low-Close (OHLC) utilizza cinque colonne di dati, in ordine: categoria, apertura, alta, bassa e chiusura. L’intervallo di prezzi in ogni categoria è nuovamente indicato da una linea verticale, mentre l’intervallo tra apertura e chiusura è dato da una barra galleggiante più ampia; se il prezzo aumenta nella categoria (chiusura è superiore all’apertura), la barra è riempita con un colore, mentre se il prezzo diminuisce, la barra è riempita con un altro. Questo tipo di grafico è spesso chiamato grafico a candela.

todo:image_alt_text

todo:image_alt_text

Miglioramenti della visibilità nel grafico

Spesso usiamo i colori invece che il bianco e nero per indicare i prezzi in aumento e in diminuzione. Nel primo set di candele di seguito, il rosso mostra i prezzi in aumento e il verde i prezzi in diminuzione.

todo:image_alt_text

Codice di Esempio

Il codice di esempio seguente carica il file Excel di esempio e genera il file Excel di output.

// Create an instance of Workbook
Workbook workbook = new Workbook("Open-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.StockOpenHighLowClose, 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 = "OPen-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:E9", true);
// Set category data
chart.NSeries.CategoryData = "A2:A9";
// Set the DownBars and UpBars with different color
chart.NSeries[0].DownBars.Area.ForegroundColor = Color.Green;
chart.NSeries[0].UpBars.Area.ForegroundColor = Color.Red;
// Fill the PlotArea area with nothing
chart.PlotArea.Area.FillFormat.FillType = FillType.None;
// Save the Excel file
workbook.Save("out.xlsx");