March 14th, 2011, 07:52 PM
Place a series of doubles into an array
Forgive me if this is a newbie question but I've spent several hours working on trying to figure out alternatives to this before I came here....I'm having some trouble in figuring out what's the best way to achieve what I'm trying to. I'd like to place a series of double values into an array without setting each value like this
double spread = CSCO.Bar.Close / DELL.Bar.Close;
if (spread_series.Count > 6)
double dataArray = new double;
dataArray = spread_series.Ago(0);
dataArray = spread_series.Ago(1) ;
dataArray = spread_series.Ago(2) ;
dataArray = spread_series.Ago(3);
dataArray = spread_series.Ago(4);
dataArray = spread_series.Ago(5);
dataArray = spread_series.Ago(6);
So in other words I'd like to to cycle though all values of spread_series.Ago(0-infinity) and place them into dataArray[i] something like this.
if (spread_series.Count > 7)
double dataArray = new double[spread_series.Count];
for (int i = 0; i < dataArray.Length; i++)
dataArray[i] = spread_series.Ago(i);
The problem obviously is that I can't implicitly convert a double into an array and the .Ago method requires an (int) in it's reference. I've tried casting but I think the underlying framework prevents it. So I'm left wondering if it's possible to make a simple class or some other method that would allow me to reference all values in the spread_series.Ago() method programmatically so that I wouldn't have to set each value individually or if I don't know how much data I'll be referencing?
Any help is greatly appreciated!
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!