I am getting an error code in the result. code below. I am basically trying to get a data set from SingleColumn method and use it in SMA method. Bu
You have some options:
SingleColumn return results and add that as a parameter to SMAresults a field of the class so it is shared.Option 1. is cleaner since it forces callers to call SingleColumn first (or come up with a list on their own)
static public double[] SingleColumn(IEnumerable strs, int highNum)
{
...
return closePrice;
}
#region Strategy Code SMA
static public void SMA(double[] closePrice)
{
int TOTAL_PERIODS = closePrice.Length;
double[] output = new double[TOTAL_PERIODS];
...
}
Note that I changed your output/input from result to closePrice since it was just converting it to a List and back. It's cleaner just to leave it as a double[]. You can also clean up the code a bit by just using ToArray instead of using ToList and then ToArray.