Page 1 of 1

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

Posted: Sun May 08, 2022 8:52 am
by 13049545
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

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

Posted: Mon May 09, 2022 9:36 am
by Christopher
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 6806 times

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

Posted: Sat Jun 18, 2022 12:44 pm
by 13049545
Thanks very much!