public static void TestGraph(this AbstractIndicator ind, string filename, int length) { Quantum q = Quantum.ExcelToQuantum(filename, "symbol", 0); var dz = new DenseMatrix(4 + 1 + ind.SubIndicatorSize, q.Data.Count); List <string> names = new List <string>(); names.Add("symbol"); names.Add(ind.ToString()); foreach (var indicator in ind.SubIndicators) { names.Add(indicator.Key); } //chartoptions ChartOption[] chartOptions = new ChartOption[names.Count]; chartOptions[0] = new ChartOption() { Height = 400, YPosition = 0 }; chartOptions[1] = new ChartOption() { Height = 200, YPosition = 1 }; for (int i = 2; i < chartOptions.Length; i++) { chartOptions[i] = new ChartOption() { Height = 0, YPosition = 1, Layover = true } } ; int counter = 0; foreach (Tick tick in q) { dz[0, counter] = tick.BidOpen; dz[1, counter] = tick.BidHigh; dz[2, counter] = tick.BidLow; dz[3, counter] = tick.BidClose; dz[4, counter] = ind.HandleNextTick(tick); int icounter = 5; foreach (var subind in ind.SubIndicators.Values) { dz[icounter, counter] = subind[0]; icounter++; } counter++; } Visualize.GenerateMultiPaneGraph(names.ToArray(), q.Data.Keys.ToArray(), dz, QSConstants.DEFAULT_DATA_FILEPATH + @"results.html", chartOptions); Console.WriteLine("Done Generating Graph for " + ind.ToString()); }
public static void TestGraphLive(this AbstractIndicator ind, string timeframe, string symbol, int length) { //------------grab data FXSession session = new FXSession(); session.InitializeSession(); HistoricPriceEngine h = new HistoricPriceEngine(session); h.GetLongHistoricPrices(symbol, timeframe, length); while (!h.Complete) { Thread.Sleep(100); } //----------------------- Quantum q = h.Data; var dz = new DenseMatrix(4 + 1 + ind.SubIndicatorSize, q.Data.Count); List <string> names = new List <string>(); names.Add("symbol"); names.Add(ind.ToString()); foreach (var indicator in ind.SubIndicators) { names.Add(indicator.Key); } //chartoptions ChartOption[] chartOptions = new ChartOption[names.Count]; chartOptions[0] = new ChartOption() { Height = 400, YPosition = 0 }; chartOptions[1] = new ChartOption() { Height = 200, YPosition = 1 }; for (int i = 2; i < chartOptions.Length; i++) { chartOptions[i] = new ChartOption() { Height = 0, YPosition = 1, Layover = true } } ; int counter = 0; foreach (Tick tick in q) { dz[0, counter] = tick.BidOpen; dz[1, counter] = tick.BidHigh; dz[2, counter] = tick.BidLow; dz[3, counter] = tick.BidClose; dz[4, counter] = ind.HandleNextTick(tick); int icounter = 5; foreach (var subind in ind.SubIndicators.Values) { dz[icounter, counter] = subind[0]; icounter++; } counter++; } Visualize.GenerateMultiPaneGraph(names.ToArray(), q.Data.Keys.ToArray(), dz, QSConstants.DEFAULT_DATA_FILEPATH + @"results.html", chartOptions); Console.WriteLine("Done Generating Graph for " + ind.ToString()); }