I have the following code:

 

using System; using System.Linq; using QuantConnect.Indicators; using QuantConnect.Models; namespace QuantConnect.Algorithm.Examples { public class QCUMovingAverageCross : QCAlgorithm { private string _symbol = "SPY"; private Symbol symbol; private Security sym; private Chart _equityChart; private DateTime StartDay = new DateTime(2020, 03, 29); private DateTime EndDay = new DateTime(2020, 06, 29); private int startCashAmount = 25000; string chartName1 = "Chart_1"; string chartName2 = "Chart_2"; public override void Initialize() { // set up our analysis span SetStartDate(StartDay); SetEndDate(EndDay); SetCash(startCashAmount); //SetBenchmark(time => 25000); sym = AddSecurity(SecurityType.Equity, _symbol, Resolution.Hour); symbol = sym.Symbol; _equityChart = new Chart(chartName1); _equityChart.AddSeries(new Series("Plot_my2", SeriesType.Candle)); AddChart(_equityChart); var myChart = new Chart(chartName2); myChart.AddSeries( new Series("Plot_my1", SeriesType.Candle) ); AddChart( myChart ); } private DateTime previous; bool sl_set=false; public void OnData(Slice data) { if (!slow.IsReady) return; //if (previous.Date == Time.Date) return; var X = Securities[symbol]; Plot(chartName2, "Plot_my1", X.Close); // Candle _equityChart.Series["Plot_my2"].AddPoint(Time+ TimeSpan.FromMinutes(1), X.Open); _equityChart.Series["Plot_my2"].AddPoint(Time+ TimeSpan.FromMinutes(2), X.High); _equityChart.Series["Plot_my2"].AddPoint(Time+ TimeSpan.FromMinutes(3), X.Low); _equityChart.Series["Plot_my2"].AddPoint(Time+ TimeSpan.FromMinutes(4), X.Close); } } }

 

and I have 2 questions:
 

1) why the "chart1" and "chart2" doesn't have same results, specifically i mean, why chart2 doesnt show the correct OHLC values of bar, while in forum examples and everywhere people had that example. Is the approach of "chart1" the only correct approach to have a candlestick chart for equity? (the same chart as we see in i.e. tradingview)

 

2) why chart2 dissapears from backtesting results page, when i click "chart1" and conversely, chart1 disappears when i click chart2 to show up. why? how can i force to show both of those windows there?

 

p.s. 3) havent anyone noticed this forum has bug? when i edit the post that contained inserted code, when i click edit again, the code has lost formatting in edit page.

Author