Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8732743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:29:36+00:00 2026-06-13T09:29:36+00:00

I am on a mission to make a candlestick graph using MSChart in a

  • 0

I am on a mission to make a candlestick graph using MSChart in a windows form. I already succeeded to make a 3D bar chart with no problems. But after a long search on the internet, Microsoft’s source code (WinSamples) and a lot of headscratching I can’t find the right way to create a candlestick graph.

What could help me is a clear example of adding a serie to the chart with multiple Y-values or a correction of my code (when i run, debug nothing shows up exept for the legend label).

A bonus would be that the example is based on OleDB (my values are in an Access database).

So my question: If you have experience with creating a Candlestick chart in C# in a windows form can you give me a hint or (even better) can you provide me with some c# code?

Here is my current (not working) code:

using System.Windows.Forms.DataVisualization.Charting;
public partial class CandleStick : Form
{
    public CandleStick()
    {
        InitializeComponent();
    }

    private void CandleStick_Load(object sender, EventArgs e)
    {
        GrafiekLaden();
    }

    public void GrafiekLaden()
    {

        Koers k = new Koers();
        // This method fills up a list, the data comes from my database
        // it contains Date, High, Low, Open, Close
        k.meerdereOphalen();

        Series price = new Series();
        chart1.Series.Add(price);

        // Set series chart type
        chart1.Series["price"].ChartType = SeriesChartType.Candlestick;

        // Set the style of the open-close marks
        chart1.Series["price"]["OpenCloseStyle"] = "Triangle";

        // Show both open and close marks
        chart1.Series["price"]["ShowOpenClose"] = "Both";

        // Set point width
        chart1.Series["price"]["PointWidth"] = "1.0";

        // Set colors bars
        chart1.Series[0]["PriceUpColor"] = "Green";
        chart1.Series[0]["PriceDownColor"] = "Red";

        for (int i = 0; i < k.Lijst.Count; i++)
        {
            // adding date and high
            chart1.Series["price"].Points.AddXY(DateTime.Parse(k.Lijst[i].Datum), k.Lijst[i].Hoog);
            // adding low
            chart1.Series["price"].Points[i].YValues[1] = k.Lijst[i].Laag;
            //adding open
            chart1.Series["price"].Points[i].YValues[2] = k.Lijst[i].PrijsOpen;
            // adding close
            chart1.Series["price"].Points[i].YValues[3] = k.Lijst[i].PrijsGesloten;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:29:37+00:00Added an answer on June 13, 2026 at 9:29 am

    Your code adds a Series not named “price”, then references both Series["price"] and Series[0] which will not be the same thing if other Series already exist. I ran a slightly modified version (faking db data with a List<>) without any problem.
    You should verify that the data coming from your DB is ok.

    enter image description here

    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }
    
        private void CandleStick_Load(object sender, EventArgs e)
        {
            GrafiekLaden();
        }
    
        public void GrafiekLaden()
        {
            // fake the DB data with a simple list
            List<dbdata> k = new List<dbdata> { 
                new dbdata("1/1/2012", 10f, 8f, 9f, 9.5f),
                new dbdata("2/1/2012", 15F, 10F, 12F, 13F),
                new dbdata("3/1/2012", 5F, 10F, 8F, 6F),
                new dbdata("4/1/2012", 25F, 10F, 18F, 16F)
            };
    
            Series price = new Series("price"); // <<== make sure to name the series "price"
            chart1.Series.Add(price);
    
            // Set series chart type
            chart1.Series["price"].ChartType = SeriesChartType.Candlestick;
    
            // Set the style of the open-close marks
            chart1.Series["price"]["OpenCloseStyle"] = "Triangle";
    
            // Show both open and close marks
            chart1.Series["price"]["ShowOpenClose"] = "Both";
    
            // Set point width
            chart1.Series["price"]["PointWidth"] = "1.0";
    
            // Set colors bars
            chart1.Series["price"]["PriceUpColor"] = "Green"; // <<== use text indexer for series
            chart1.Series["price"]["PriceDownColor"] = "Red"; // <<== use text indexer for series
    
            for (int i = 0; i < k.Count; i++)
            {
                // adding date and high
                chart1.Series["price"].Points.AddXY(DateTime.Parse(k[i].Datum), k[i].Hoog);
                // adding low
                chart1.Series["price"].Points[i].YValues[1] = k[i].Laag;
                //adding open
                chart1.Series["price"].Points[i].YValues[2] = k[i].PrijsOpen;
                // adding close
                chart1.Series["price"].Points[i].YValues[3] = k[i].PrijsGesloten;
            }
        }
    }
    
    class dbdata
    {
        public string Datum;
        public float Hoog;
        public float Laag;
        public float PrijsOpen;
        public float PrijsGesloten;
        public dbdata(string d, float h, float l, float o, float c) { Datum = d; Hoog = h; Laag = l; PrijsOpen = o; PrijsGesloten = c; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the mission to make a small game for a school project. Pictures
The Mission: Apply a generic template to chart series. My Template File: <Chart BackColor=211,
Mission: Draw two lines with different color on one graph with automatic cliping, by
I have following JavaScript function to make some calculation with textboxes but when I
I can run this code in Android app (using PhoneGap adn jQuery Mobile) but
I want to make a case insensitive mongoid query on a mission title. Lets
Hey, I'm having trouble with this side bar I'm trying to make. It wont
im using linq to sql i have a Mission entity, which holds a collection
My mission is to graduate from using PowerShell to create an instance of Outlook
Mission: Display data in a program on a PC. Extended mission: (after solving this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.