Iterate through Chart and Scrape Bollinger Upper, Lower, and Middle Band Values???

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
jzarech
Newbie
Newbie
Posts: 58
Joined: Mon Jul 07, 2008 12:00 am

Iterate through Chart and Scrape Bollinger Upper, Lower, and Middle Band Values???

Post by jzarech » Sun May 08, 2022 8:52 am

Hi Steema Techs,

I would like to iterate through all the Values on a chart and Scrape the Bollinger Values for Upper, Lower, and Middle band as well as Date.

Do you have any sample code anywhere that shows how to do this?

I only see X and Y values.

Thanks so much,

Joseph

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Iterate through Chart and Scrape Bollinger Upper, Lower, and Middle Band Values???

Post by Christopher » Mon May 09, 2022 9:36 am

Hello Joseph,

Yes, the Bollinger Bands are hidden series, but you can pull the values out with code like this (move the mouse over the top band to get the values):

Code: Select all

    public Form1()
    {
      InitializeComponent();

      Candle series = new Candle(tChart1.Chart);
      FastLine funcSeries = new FastLine(tChart1.Chart);

      Bollinger function = new Bollinger(tChart1.Chart)
      {
        Period = 50,
        Deviation = 2
      };

      funcSeries.DataSource = series;
      funcSeries.Function = function;

      series.FillSampleValues(400);

      CursorTool cursor = new CursorTool(tChart1.Chart)
      {
        Style = CursorToolStyles.Vertical,
        FollowMouse = true,
        Series = funcSeries
      };
      cursor.Change += Cursor_Change;
      tChart1.Header.Font.Size = 10;

      void Cursor_Change(object sender, CursorChangeEventArgs e)
      {
        if (e.ValueIndex > -1)
        {
          System.Collections.Generic.List<FastLine> lineSeries = tChart1.Series.OfType<FastLine>().ToList();
          tChart1.Header.Text = string.Join("\n", lineSeries.Select(x => $"XValue {DateTime.FromOADate(x.XValues[e.ValueIndex])}, YValue {x.YValues[e.ValueIndex]}"));
        }
      }
    }
Here this gives me:
Screenshot from 2022-05-09 11-33-47.png
Screenshot from 2022-05-09 11-33-47.png (33.15 KiB) Viewed 6810 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

jzarech
Newbie
Newbie
Posts: 58
Joined: Mon Jul 07, 2008 12:00 am

Re: Iterate through Chart and Scrape Bollinger Upper, Lower, and Middle Band Values???

Post by jzarech » Sat Jun 18, 2022 12:44 pm

Thanks very much!

Post Reply