public void GetInput(AxSTOCKCHARTXLib.AxStockChartX Chart, string PriceStyle) { m_StockChartX = Chart; txtInputA.Visible = false; txtInputB.Visible = false; txtInputC.Visible = false; lblInputA.Text = ""; lblInputB.Text = ""; lblInputC.Text = ""; m_PriceStyle = PriceStyle; switch (m_PriceStyle) { case "Point && Figure": txtInputA.Text = m_StockChartX.get_PriceStyleParam(1).ToString(); lblInputA.Text = "Box Size"; txtInputA.Visible = true; lblInputA.Visible = true; txtInputB.Text = m_StockChartX.get_PriceStyleParam(2).ToString(); lblInputB.Text = "Reversal Size"; txtInputB.Visible = true; lblInputB.Visible = true; break; case "Three Line Break": txtInputA.Text = m_StockChartX.get_PriceStyleParam(1).ToString(); lblInputA.Text = "Line Break"; txtInputA.Visible = true; lblInputA.Visible = true; break; case "Renko": txtInputA.Text = m_StockChartX.get_PriceStyleParam(1).ToString(); lblInputA.Text = "Box Size"; txtInputA.Visible = true; lblInputA.Visible = true; break; case "Kagi": txtInputA.Text = m_StockChartX.get_PriceStyleParam(1).ToString(); lblInputA.Text = "Reversal Size"; txtInputA.Visible = true; lblInputA.Visible = true; txtInputB.Text = m_StockChartX.get_PriceStyleParam(2).ToString(); lblInputB.Text = "Points or Pct"; txtInputB.Visible = true; lblInputB.Visible = true; break; } ShowDialog(); }
private void DisplayResults(string Results) { if (string.IsNullOrEmpty(Results)) { MessageBox.Show("No results. Make sure that at least Buy and Sell scripts are typed in."); return; } //Translate log: Results = Results.Replace("LONG", "COMPRA"); Results = Results.Replace("SHORT", "VENDA"); int found = Results.IndexOf("Log:"); AxSTOCKCHARTXLib.AxStockChartX StockChartX1 = m_chart.StockChartX1; if (found > 0) { int n; string[] tradeLog = Results.Substring(found + "Log:".Length + 1).Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string[] report = Results.Substring(0, found - 1).Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); //Loop through the trade log and the statistical report m_ListTrades.Items.Clear(); m_ListTrades.Items.Add(report[0].Replace("Back-Test de ", "")); for (n = 1; n < report.Length; n++) { m_ListTrades.Items.Add(report[n]); } //Get the trade for (n = 0; n < tradeLog.Length; n++) { long record; double value; m_ListTrades.Items.Add(tradeLog[n]); string[] trade = tradeLog[n].Split(','); double jDate = GetJDate(trade[0]); string signal = trade[1]; double price = double.Parse(trade[2]); switch (signal) { case "LONG": case "COMPRA": record = StockChartX1.GetRecordByJDate(jDate); value = StockChartX1.GetValue(StockChartX1.Symbol + ".low", (int)record); StockChartX1.AddSymbolObject(0, value, (int)record, STOCKCHARTXLib.SymbolType.soBuySymbolObject, "BUY " + Convert.ToString(record), "Compra a $" + Convert.ToString(price)); break; case "SHORT": case "VENDA": record = StockChartX1.GetRecordByJDate(jDate); value = StockChartX1.GetValue(StockChartX1.Symbol + ".high", (int)record); StockChartX1.AddSymbolObject(0, value, (int)record, STOCKCHARTXLib.SymbolType.soSellSymbolObject, "SELL " + Convert.ToString(record), "Venda a $" + Convert.ToString(price)); break; case "EXIT": record = StockChartX1.GetRecordByJDate(jDate); StockChartX1.AddSymbolObject(0, price, (int)record, STOCKCHARTXLib.SymbolType.soExitSymbolObject, "EXIT " + Convert.ToString(record), "Exit at $" + Convert.ToString(price)); break; } } m_ListTrades.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } try { StockChartX1.ForcePaint(); } catch (Exception) { } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmTestVWAP)); this.axStockChartX1 = new AxSTOCKCHARTXLib.AxStockChartX(); this.pnlTop = new System.Windows.Forms.Panel(); this.btnZoomIn = new System.Windows.Forms.Button(); this.btnZoomOut = new System.Windows.Forms.Button(); this.btnRight = new System.Windows.Forms.Button(); this.btnLeft = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.txtLength = new System.Windows.Forms.TextBox(); this.btnVWAP = new System.Windows.Forms.Button(); this.btnBrowse = new System.Windows.Forms.Button(); this.txtPath = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.axStockChartX1)).BeginInit(); this.pnlTop.SuspendLayout(); this.SuspendLayout(); // // axStockChartX1 // this.axStockChartX1.Dock = System.Windows.Forms.DockStyle.Fill; this.axStockChartX1.Enabled = true; this.axStockChartX1.Location = new System.Drawing.Point(0, 80); this.axStockChartX1.Name = "axStockChartX1"; this.axStockChartX1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axStockChartX1.OcxState"))); this.axStockChartX1.Size = new System.Drawing.Size(688, 406); this.axStockChartX1.TabIndex = 0; // // pnlTop // this.pnlTop.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pnlTop.Controls.Add(this.btnZoomIn); this.pnlTop.Controls.Add(this.btnZoomOut); this.pnlTop.Controls.Add(this.btnRight); this.pnlTop.Controls.Add(this.btnLeft); this.pnlTop.Controls.Add(this.label1); this.pnlTop.Controls.Add(this.txtLength); this.pnlTop.Controls.Add(this.btnVWAP); this.pnlTop.Controls.Add(this.btnBrowse); this.pnlTop.Controls.Add(this.txtPath); this.pnlTop.Dock = System.Windows.Forms.DockStyle.Top; this.pnlTop.ForeColor = System.Drawing.Color.Gainsboro; this.pnlTop.Location = new System.Drawing.Point(0, 0); this.pnlTop.Name = "pnlTop"; this.pnlTop.Size = new System.Drawing.Size(688, 80); this.pnlTop.TabIndex = 11; // // btnZoomIn // this.btnZoomIn.BackColor = System.Drawing.Color.WhiteSmoke; this.btnZoomIn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnZoomIn.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.btnZoomIn.ForeColor = System.Drawing.Color.DarkBlue; this.btnZoomIn.Location = new System.Drawing.Point(112, 40); this.btnZoomIn.Name = "btnZoomIn"; this.btnZoomIn.Size = new System.Drawing.Size(32, 23); this.btnZoomIn.TabIndex = 19; this.btnZoomIn.Text = "+"; this.btnZoomIn.Click += new System.EventHandler(this.btnZoomIn_Click); // // btnZoomOut // this.btnZoomOut.BackColor = System.Drawing.Color.WhiteSmoke; this.btnZoomOut.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnZoomOut.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.btnZoomOut.ForeColor = System.Drawing.Color.DarkBlue; this.btnZoomOut.Location = new System.Drawing.Point(80, 40); this.btnZoomOut.Name = "btnZoomOut"; this.btnZoomOut.Size = new System.Drawing.Size(32, 23); this.btnZoomOut.TabIndex = 18; this.btnZoomOut.Text = "-"; this.btnZoomOut.Click += new System.EventHandler(this.btnZoomOut_Click); // // btnRight // this.btnRight.BackColor = System.Drawing.Color.WhiteSmoke; this.btnRight.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnRight.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.btnRight.ForeColor = System.Drawing.Color.DarkBlue; this.btnRight.Location = new System.Drawing.Point(40, 40); this.btnRight.Name = "btnRight"; this.btnRight.Size = new System.Drawing.Size(32, 23); this.btnRight.TabIndex = 17; this.btnRight.Text = ">"; this.btnRight.Click += new System.EventHandler(this.btnRight_Click_1); // // btnLeft // this.btnLeft.BackColor = System.Drawing.Color.WhiteSmoke; this.btnLeft.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnLeft.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.btnLeft.ForeColor = System.Drawing.Color.DarkBlue; this.btnLeft.Location = new System.Drawing.Point(8, 40); this.btnLeft.Name = "btnLeft"; this.btnLeft.Size = new System.Drawing.Size(32, 23); this.btnLeft.TabIndex = 16; this.btnLeft.Text = "<"; this.btnLeft.Click += new System.EventHandler(this.btnLeft_Click_1); // // label1 // this.label1.BackColor = System.Drawing.Color.Black; this.label1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label1.ForeColor = System.Drawing.Color.White; this.label1.Location = new System.Drawing.Point(416, 8); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(40, 16); this.label1.TabIndex = 15; this.label1.Text = "Length"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // txtLength // this.txtLength.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtLength.ForeColor = System.Drawing.Color.DarkBlue; this.txtLength.Location = new System.Drawing.Point(464, 8); this.txtLength.Name = "txtLength"; this.txtLength.Size = new System.Drawing.Size(56, 20); this.txtLength.TabIndex = 13; this.txtLength.Text = ""; // // btnVWAP // this.btnVWAP.BackColor = System.Drawing.Color.WhiteSmoke; this.btnVWAP.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnVWAP.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.btnVWAP.ForeColor = System.Drawing.Color.DarkBlue; this.btnVWAP.Location = new System.Drawing.Point(528, 8); this.btnVWAP.Name = "btnVWAP"; this.btnVWAP.TabIndex = 14; this.btnVWAP.Text = "VWAP"; this.btnVWAP.Click += new System.EventHandler(this.btnVWAP_Click); // // btnBrowse // this.btnBrowse.BackColor = System.Drawing.Color.WhiteSmoke; this.btnBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnBrowse.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.btnBrowse.ForeColor = System.Drawing.Color.DarkBlue; this.btnBrowse.Location = new System.Drawing.Point(328, 8); this.btnBrowse.Name = "btnBrowse"; this.btnBrowse.TabIndex = 12; this.btnBrowse.Text = "Browse..."; this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click); // // txtPath // this.txtPath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtPath.ForeColor = System.Drawing.Color.DarkBlue; this.txtPath.Location = new System.Drawing.Point(8, 8); this.txtPath.Name = "txtPath"; this.txtPath.Size = new System.Drawing.Size(312, 20); this.txtPath.TabIndex = 11; this.txtPath.Text = ""; // // frmTestVWAP // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(688, 486); this.Controls.Add(this.axStockChartX1); this.Controls.Add(this.pnlTop); this.Name = "frmTestVWAP"; this.Text = "TestVWAP"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.axStockChartX1)).EndInit(); this.pnlTop.ResumeLayout(false); this.ResumeLayout(false); }
//Runs the backtest and displays the chart with buy/sell/exit icons. private string RunBacktest() { string ret = string.Empty; try { oScript.ClearRecords(); oBacktest.ClearRecords(); if (!VerifyForm()) { return(string.Empty); } if (!TestScripts()) { return(string.Empty); } if (m_ctlData == null) { return(string.Empty); } cmdBacktest.Text = "&Stop Backtest"; EnableControls(false); Periodicity periodicity; switch (cboPeriodicity.Text) { case "Minute": periodicity = Periodicity.Minutely; break; case "Hour": periodicity = Periodicity.Hourly; break; case "Day": periodicity = Periodicity.Daily; break; case "Week": periodicity = Periodicity.Weekly; break; default: periodicity = Periodicity.Minutely; break; } cmdBacktest.Enabled = false; Telerik.WinControls.UI.Docking.DockWindow activeDoc = frmMain2.GInstance.radDock2.DocumentManager.ActiveDocument; //Get the data selection M4Core.Entities.ChartSelection selection = new M4Core.Entities.ChartSelection { Periodicity = (M4Core.Entities.Periodicity)periodicity, Symbol = txtSymbol.Text, Interval = Convert.ToInt32(txtInterval.Text), Bars = Convert.ToInt32(txtBars.Text) }; m_ctlData.LoadRealTimeCtlPainelChartAsync2(selection, new Action <CtlPainelChart>(chart => { m_chart = chart; if (m_chart == null) { goto Quit; } DataManager.BarData[] bars = m_chart.GetDataFromChart(); if (bars.Length < 1) { goto Quit; } m_chart.Subscribers += 1; m_chart.RealTimeUpdates = false; //Get historic data cmdBacktest.Enabled = true; if (bars.Length < 3) { goto Quit; //Bad request } //Insert the data into all four instances of TradeScript oScript.ClearRecords(); oBacktest.ClearRecords(); DateTime td; double jdate; for (int n = 1; n < bars.Length - 1; n++) { td = bars[n].TradeDate; jdate = oScript.ToJulianDate(td.Year, td.Month, td.Day, td.Hour, td.Minute, td.Second, 0); oScript.AppendRecord(jdate, bars[n].OpenPrice, bars[n].HighPrice, bars[n].LowPrice, bars[n].ClosePrice, (int)bars[n].Volume); oBacktest.AppendRecord(jdate, bars[n].OpenPrice, bars[n].HighPrice, bars[n].LowPrice, bars[n].ClosePrice, (int)bars[n].Volume); } //TODO ret = oBacktest.Backtest(txtBuyScript, txtSellScript, txtExitLongScript, txtExitShortScript, 0.001); if (string.IsNullOrEmpty(ret)) { goto Quit; } string output = oScript.GetScriptOutput(txtBuyScript + " AND \r\n" + txtSellScript + " AND \r\n" + txtExitLongScript + " AND \r\n" + txtExitShortScript); if (string.IsNullOrEmpty(output)) { goto Quit; } int row; string[] cols; int col; string[] rows = output.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string[] Header = SplitHeader(rows[0]); //StockChartX AxSTOCKCHARTXLib.AxStockChartX StockChartX1 = m_chart.StockChartX1; StockChartX1.RemoveAllSeries(); string symbol = selection.Symbol; StockChartX1.Symbol = symbol; StockChartX1.AddChartPanel(); StockChartX1.AddSeries(symbol + ".open", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.AddSeries(symbol + ".high", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.AddSeries(symbol + ".low", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.AddSeries(symbol + ".close", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.set_SeriesColor(symbol + ".close", ColorTranslator.ToOle(Color.Black)); //OLD BEHAVIOR: Add generic serie /* * for (col = 6; col < Header.Length; col++) * { * int panel = 0; * panel = StockChartX1.AddChartPanel(); * * StockChartX1.AddSeries(Header[col], STOCKCHARTXLib.SeriesType.stLineChart, panel); * * System.Drawing.Color color; * switch (col) * { * case 6: * color = System.Drawing.Color.Blue; * break; * case 7: * color = System.Drawing.Color.Red; * break; * case 8: * color = System.Drawing.Color.Green; * break; * case 9: * color = System.Drawing.Color.Orange; * break; * case 10: * color = System.Drawing.Color.Purple; * break; * default: * color = System.Drawing.Color.Blue; * break; * } * StockChartX1.set_SeriesColor(Header[col], System.Drawing.ColorTranslator.ToOle(color)); * * }*/ for (row = 1; row < rows.Length; row++) { cols = rows[row].Split(','); jdate = GetJDate(cols[0]); StockChartX1.AppendValue(symbol + ".open", jdate, Convert.ToDouble(cols[1], ciEnUs)); StockChartX1.AppendValue(symbol + ".high", jdate, Convert.ToDouble(cols[2], ciEnUs)); StockChartX1.AppendValue(symbol + ".low", jdate, Convert.ToDouble(cols[3], ciEnUs)); StockChartX1.AppendValue(symbol + ".close", jdate, Convert.ToDouble(cols[4], ciEnUs)); //OLD BEHAVIOR: Add generic serie /* * for (col = 6; col < cols.Length; col++) * { * double value = Convert.ToDouble(cols[col], ciEnUs); * if (value == 0 && row < rows.Length * 0.2) * { * value = (double)STOCKCHARTXLib.DataType.dtNullValue; * } * * StockChartX1.AppendValue(Header[col], jdate, value); * } */ } //NEW BEHAVIOR: Add known indicators (it doesnt work with others indicators!) for (col = 6; col < Header.Length; col++) { //Try to add until available key isnt found: bool errorKey = true; int indicatorKey = 1; while (errorKey) { try { System.Drawing.Color color; switch (col) { case 6: color = System.Drawing.Color.Blue; break; case 7: color = System.Drawing.Color.Red; break; case 8: color = System.Drawing.Color.Green; break; case 9: color = System.Drawing.Color.Orange; break; case 10: color = System.Drawing.Color.Purple; break; default: color = System.Drawing.Color.Blue; break; } //param[0 1 2 3] // MM(1,14,CLOSE,0) if (Header[col].Contains("MM(")) { string indScript = Header[col].Replace("MM(", ""); indScript = indScript.Replace(")", ""); string[] param = indScript.Split(new char[] { ',' }); string source = symbol + ".Close"; switch (param[2]) { case "OPEN": source = symbol + ".Open"; break; case "HIGH": source = symbol + ".High"; break; case "LOW": source = symbol + ".Low"; break; default: source = symbol + ".Close"; break; } StockChartX1.AddIndicatorGenericMovingAverage("MA" + indicatorKey, 0, source, int.Parse(param[1]), int.Parse(param[3]), int.Parse(param[0]), 0, color.R, color.G, color.B, 0, 1); } errorKey = false; } catch (Exception ex) { if (ex.Message == "Key not unique") { errorKey = true; indicatorKey++; } else { Telerik.WinControls.RadMessageBox.Show(ex.Message); } } } } StockChartX1.Update(); Quit: if (m_chart != null) { m_chart.Show(); } cmdBacktest.Text = "&Back Test"; EnableControls(true); if (m_chart != null) { m_chart.Subscribers -= 1; } })); //Ensure the chart is new while (ret == string.Empty) { Application.DoEvents(); } } catch (Exception ex) { } return(ret); }
//Runs the backtest and displays the chart with buy/sell/exit icons. private string RunBacktest() { string ret = string.Empty; _oScript.ClearRecords(); _oBacktest.ClearRecords(); if (!VerifyForm()) { return(string.Empty); } if (!TestScripts()) { return(string.Empty); } if (_mCtlData == null) { return(string.Empty); } cmdBacktest.Text = "&Stop Backtest"; cmdBacktest.Border.BaseColor = Color.Red; EnableControls(false); cmdBacktest.Border.Update(); Periodicity periodicity; switch (cboPeriodicity.Text) { case "Day": periodicity = Periodicity.Daily; break; case "Hour": periodicity = Periodicity.Hourly; break; case "Minute": periodicity = Periodicity.Minutely; break; case "Week": periodicity = Periodicity.Weekly; break; case "Month": periodicity = Periodicity.Month; break; case "Year": periodicity = Periodicity.Year; break; default: periodicity = Periodicity.Minutely; break; } cmdBacktest.Enabled = false; //Get the data selection ChartSelection selection = new ChartSelection { Periodicity = periodicity, Symbol = txtSymbol.Text, Interval = Convert.ToInt32(txtInterval.Text), Bars = Convert.ToInt32(txtBars.Text), Source = "PLENA" }; _ctlPainelChart = _mCtlData.GetCtlPainelChart(selection, true); //Ensure the chart is new if (_ctlPainelChart == null) { goto Quit; } DataManager.BarData[] bars = _ctlPainelChart.GetDataFromChart(); if (bars.Length < 1) { goto Quit; } _ctlPainelChart.Subscribers += 1; _ctlPainelChart.RealTimeUpdates = false; //Get historic data cmdBacktest.Enabled = true; if (bars.Length < 3) { goto Quit; //Bad request } //Insert the data into all four instances of TradeScript _oScript.ClearRecords(); _oBacktest.ClearRecords(); DateTime td; double jdate; for (int n = 1; n < bars.Length - 1; n++) { td = bars[n].TradeDate; jdate = _oScript.ToJulianDate(td.Year, td.Month, td.Day, td.Hour, td.Minute, td.Second, 0); _oScript.AppendRecord(jdate, bars[n].OpenPrice, bars[n].HighPrice, bars[n].LowPrice, bars[n].ClosePrice, (int)bars[n].Volume); _oBacktest.AppendRecord(jdate, bars[n].OpenPrice, bars[n].HighPrice, bars[n].LowPrice, bars[n].ClosePrice, (int)bars[n].Volume); } //TODO ret = _oBacktest.Backtest(txtBuyScript.Text, txtSellScript.Text, txtExitLongScript.Text, txtExitShortScript.Text, 0.001); if (string.IsNullOrEmpty(ret)) { goto Quit; } string output = _oScript.GetScriptOutput(txtBuyScript.Text + " AND \r\n" + txtSellScript.Text + " AND \r\n" + txtExitLongScript.Text + " AND \r\n" + txtExitShortScript.Text); if (string.IsNullOrEmpty(output)) { goto Quit; } int row; string[] cols; int col; string[] rows = output.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string[] header = SplitHeader(rows[0]); //StockChartX AxSTOCKCHARTXLib.AxStockChartX StockChartX1 = _ctlPainelChart.StockChartX1; StockChartX1.RemoveAllSeries(); string symbol = selection.Symbol; StockChartX1.Symbol = symbol; StockChartX1.AddChartPanel(); StockChartX1.AddSeries(symbol + ".open", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.AddSeries(symbol + ".high", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.AddSeries(symbol + ".low", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.AddSeries(symbol + ".close", STOCKCHARTXLib.SeriesType.stCandleChart, 0); StockChartX1.set_SeriesColor(symbol + ".close", ColorTranslator.ToOle(Color.Black)); bool hasVolume = bars[0].Volume != -987654321; if (hasVolume) { StockChartX1.AddChartPanel(); StockChartX1.AddSeries(symbol + ".volume", STOCKCHARTXLib.SeriesType.stVolumeChart, 1); StockChartX1.set_SeriesColor(symbol + ".volume", ColorTranslator.ToOle(Color.Blue)); StockChartX1.set_SeriesWeight(symbol + ".volume", 3); StockChartX1.VolumePostfixLetter = "M"; //Google trades in millions } for (col = 6; col < header.Length; col++) { int panel = StockChartX1.AddChartPanel(); StockChartX1.AddSeries(header[col], STOCKCHARTXLib.SeriesType.stLineChart, panel); Color color; switch (col) { case 6: color = Color.Blue; break; case 7: color = Color.Red; break; case 8: color = Color.Green; break; case 9: color = Color.Orange; break; case 10: color = Color.Purple; break; default: color = Color.Blue; break; } StockChartX1.set_SeriesColor(header[col], ColorTranslator.ToOle(color)); } for (row = 1; row < rows.Length; row++) { cols = rows[row].Split(','); jdate = GetJDate(cols[0]); StockChartX1.AppendValue(symbol + ".open", jdate, Convert.ToDouble(cols[1], _ciEnUs)); StockChartX1.AppendValue(symbol + ".high", jdate, Convert.ToDouble(cols[2], _ciEnUs)); StockChartX1.AppendValue(symbol + ".low", jdate, Convert.ToDouble(cols[3], _ciEnUs)); StockChartX1.AppendValue(symbol + ".close", jdate, Convert.ToDouble(cols[4], _ciEnUs)); if (hasVolume) { StockChartX1.AppendValue(symbol + ".volume", jdate, Convert.ToDouble(cols[5], _ciEnUs) / 1000000); } for (col = 6; col < cols.Length; col++) { double value = Convert.ToDouble(cols[col], _ciEnUs); if (value == 0 && row < rows.Length * 0.2) { value = (double)STOCKCHARTXLib.DataType.dtNullValue; } StockChartX1.AppendValue(header[col], jdate, value); } } StockChartX1.Update(); Quit: if (_ctlPainelChart != null) { _ctlPainelChart.Show(); } cmdBacktest.Text = "&Back Test"; cmdBacktest.Border.BaseColor = Color.Lime; EnableControls(true); cmdBacktest.Border.Update(); if (_ctlPainelChart != null) { _ctlPainelChart.Subscribers -= 1; } return(ret); }