2 Replies - 281 Views - Last Post: 24 October 2017 - 02:45 AM Rate Topic: -----

#1 C#RL  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-October 17

how to use chart.FinancialFormula? C#

Posted 23 October 2017 - 03:17 PM

Hi

I'm trying to use chart.DataManipulation.FinancialFormula with no success.
I've spent at least 50 hours trying to solve this so thats why I'm posting the question here now.

I don't think posting any of my code here will help since I've got nowhere so far.

The formula I'm trying to use:
https://msdn.microso...y/dd456678.aspx


-I have a DataTable with my data (Date, Open, Close, Low, High) collected from a database.

-I want to do the calculation with FinancialFormula.RelativeStrengthIndex and store the output in a DataTable togheter with Date, Open, Close, Low, High from the first DataTable for further calculations.

For now Im not going to do any visual presentation of the output so I will not present any chart in my WindowsFormsApp.

Thanks for your time

Is This A Good Question/Topic? 0
  • +

Replies To: how to use chart.FinancialFormula? C#

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5890
  • View blog
  • Posts: 20,102
  • Joined: 05-May 12

Re: how to use chart.FinancialFormula? C#

Posted 23 October 2017 - 05:08 PM

Posting your code will help us from retreading paths that you have considered deadends, as well as give interested people a starting point for fiddling around.

From my reading of the documentation you looked to it looks like that function reads and writes from/to charts, not data tables.
Was This Post Helpful? 0
  • +
  • -

#3 C#RL  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-October 17

Re: how to use chart.FinancialFormula? C#

Posted 24 October 2017 - 02:45 AM

View PostSkydiver, on 23 October 2017 - 05:08 PM, said:

Posting your code will help us from retreading paths that you have considered deadends, as well as give interested people a starting point for fiddling around.

From my reading of the documentation you looked to it looks like that function reads and writes from/to charts, not data tables.


This is what I've been playing around with.
I call a function to get my data from my database
I then store the result in a DataTable (dt).

public void Test()
        {
            Connections conn = new Connections();

            //Load Datatable from database
            DataTable dt = new DataTable();
            dt = conn.ExtractDataFromDbHighLow("ABB");     //"ABB" name of the stock

            //---------------this section doesn't work -----------
            //I get rownumber instead of date that's stored in the first[0] column of my table
            //and I get no output

            //iterate table and store in series
            //Series priceSerie = new Series();
            /*
            foreach (DataRow rows in dt.Rows)
            {
                //priceSerie.Points.DataBindXY(dt.Rows);
                priceSerie.Points.AddXY(rows[0], rows[1]);        //stores rownumber in x-value and not date??
            }*/

            //this.chart1.Series.Add(priceSerie);

            //this.chart2.Series.Add(priceSerie);
            
            //--------------------------------------------------------

            //this part gives me a price chart of my stock. 
            //it's a test to see that I got data into a series and it seems to work
            chart1.Series.Add("Daily");
            chart1.Series["Daily"].ChartType = SeriesChartType.Candlestick;
            chart1.Series["Daily"].XValueMember = "Date";
            chart1.Series["Daily"].YValueMembers = "Open, Low, High, Close";
            chart1.Series["Daily"].XValueType = ChartValueType.Date;
            chart1.DataSource = dt;
            chart1.DataBind();

            //here I try to create another series to pass to the financial formula 
            chart2.Series.Add("Daily2");
            chart2.Series["Daily2"].ChartType = SeriesChartType.Line;
            chart2.Series["Daily2"].XValueMember = "Date";
            chart2.Series["Daily2"].YValueMembers = "Open, Low, High, Close";
            chart2.Series["Daily2"].XValueType = ChartValueType.Date;
            chart2.DataSource = dt;
            
            //error on the input series and program crash
            this.chart2.DataManipulator.FinancialFormula(FinancialFormula.RelativeStrengthIndex, "2", "Daily2", "RSI");
            //how do I put output ("RSI") into a datatable
        }

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1