Created
October 21, 2012 04:24
-
-
Save gerardo/3925708 to your computer and use it in GitHub Desktop.
MACD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Action(object sender, RoutedEventArgs e) | |
{ | |
int i; | |
string curDir=Directory.GetCurrentDirectory(); | |
string fileName=curDir+@"\msft.csv"; | |
List<string[]> parsedData = parseCSV(fileName); | |
int nCount = parsedData.Count; | |
double[] closingPricesArr = new double[nCount - 1]; | |
for (i = 0; i < nCount - 1; i++) | |
closingPricesArr[i] = Convert.ToDouble(parsedData[i + 1][6]); | |
int startIdx = 100; | |
int endIdx = 1000; | |
int optInFastPeriod = 12; | |
int optInSlowPeriod = 26; | |
int optInSignalPeriod = 9; | |
double[] inReal = closingPricesArr; | |
int outBegIdx; | |
int outNBElement; | |
double[] outMACD = new double[endIdx - startIdx+1]; | |
double[] outMACDSignal = new double[endIdx - startIdx + 1]; | |
double[] outMACDHist = new double[endIdx - startIdx + 1]; | |
Core.RetCode res = Core.Macd(startIdx, endIdx, inReal, optInFastPeriod, optInSlowPeriod, optInSignalPeriod, out outBegIdx, out outNBElement, outMACD, outMACDSignal, outMACDHist); | |
List<Macdres> resarr = new List<Macdres>(endIdx - startIdx + 1); | |
int counter=0; | |
for (i = startIdx; i < endIdx - startIdx + 1; i++) | |
{ | |
Macdres macdres = new Macdres(); | |
macdres.Index = i; | |
macdres.Macd = outMACD[counter]; | |
macdres.Signal = outMACDSignal[counter]; | |
macdres.MacdHistogram = outMACDHist[counter]; | |
resarr.Add(macdres); | |
counter++; | |
} | |
listView1.ItemsSource = resarr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment