Skip to content

Instantly share code, notes, and snippets.

@sthewissen
Created November 3, 2017 08:41
Show Gist options
  • Save sthewissen/44d87a1b5651da6aa553ed2cec9189ad to your computer and use it in GitHub Desktop.
Save sthewissen/44d87a1b5651da6aa553ed2cec9189ad to your computer and use it in GitHub Desktop.
public static List<double?> Sma(this List<double> source, int period = 30)
{
int outBegIdx, outNbElement;
double[] smaValues = new double[source.Count];
List<double?> outValues = new List<double?>();
var sma = TA.Library.Core.Sma(0, source.Count - 1, source.ToArray(), period, out outBegIdx, out outNbElement, smaValues);
if (sma == TA.Library.Core.RetCode.Success)
{
FixIndicatorOrdering(smaValues.ToList(), outBegIdx, outNbElement);
}
throw new Exception("Could not calculate SMA!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment