Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Create array with only X values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Create array with only X values

    I am somewhat familiar with the DataSeries class which normally contains the same number of elements as bars in a chart.

    Is there another way to limit the number of elements of a DataSeries? Say I only wanted my DataSeries to contain 100 elements and never more than 100. Can this be done, and if so, how?

    Thanks

    #2
    Hi Pepperdog,

    my shot for a framework.
    The access to the data collection is done with the related bar number. If you operate with CurrentBar, then the last 100 values are stored.
    Code is not tested.

    Regards
    Ralph
    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][FONT=Courier New]using[/FONT][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][FONT=Courier New][SIZE=2] System.Collections.Generic;[/SIZE][/FONT][/SIZE]
     
    [SIZE=2][SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][FONT=Courier New]private[/FONT][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][FONT=Courier New][SIZE=2][SIZE=2][COLOR=#000000] List<[COLOR=#0000ff]double[/COLOR]> barData = [/COLOR][/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2][COLOR=#000000] List<[COLOR=#0000ff]double[/COLOR]>();[/COLOR][/SIZE][/SIZE][/FONT]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][FONT=Courier New]private [/FONT][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2][COLOR=#000000] listSize = 100;[/COLOR][/SIZE][/SIZE][/FONT]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2][COLOR=#000000] WriteBarData([COLOR=#0000ff]int [COLOR=#000000]barID, [COLOR=#0000ff]double[/COLOR] barValue[/COLOR][/COLOR])[/COLOR][/SIZE][/SIZE][/FONT]
    [SIZE=2][SIZE=2][FONT=Courier New][COLOR=#000000]{[/COLOR][/FONT][/SIZE][/SIZE]
    [FONT=Courier New][COLOR=#000000] barData[barID % listSize] = barValue;[/COLOR][/FONT]
    [SIZE=2][SIZE=2][FONT=Courier New][COLOR=#000000]}[/COLOR][/FONT][/SIZE][/SIZE]
    [SIZE=2][SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2][COLOR=#000000] ReadBarData([COLOR=#0000ff]int [COLOR=#000000]barID[/COLOR][/COLOR])[/COLOR][/SIZE][/SIZE][/FONT]
    [SIZE=2][SIZE=2][FONT=Courier New][COLOR=#000000]{[/COLOR][/FONT][/SIZE][/SIZE]
    [FONT=Courier New][COLOR=#000000] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return [/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]barData[barID % listSize];[/COLOR][/FONT]
    [SIZE=2][SIZE=2][FONT=Courier New][COLOR=#000000]}[/COLOR][/FONT][/SIZE]
    [/SIZE][/SIZE][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/SIZE][/SIZE]

    Comment


      #3
      Thanks for posting this code snippet Ralph!

      Here is a link to ArrayLists on MSDN - http://msdn.microsoft.com/en-us/libr...arraylist.aspx

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      331 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      550 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X