예제 #1
0
        public double Process(SmaData data, int i, MinMax minmax = null, int nLookahead = 0, bool bAddToParams = false)
        {
            bool bActive = data.SrcData[i].Active;

            PlotCollection dataSrc = data.SrcData;
            PlotCollection dataDst = data.DstData;
            double         dfInc   = data.Increment;

            if (bActive)
            {
                if (data.Count < m_config.Interval)
                {
                    data.SMA += dataSrc[i].Y * dfInc;

                    if (dataDst != null)
                    {
                        dataDst.Add(dataSrc[i].X, dataSrc[i].Y, false, dataSrc[i].Index);
                    }
                }
                else
                {
                    if (i < dataSrc.Count - nLookahead)
                    {
                        data.SMA = (data.SMA * (1 - dfInc)) + dataSrc[i].Y * dfInc;
                    }

                    if (dataDst != null)
                    {
                        dataDst.Add(dataSrc[i].X, data.SMA, true, dataSrc[i].Index);
                    }

                    if (bAddToParams)
                    {
                        dataSrc[i].SetParameter(dataDst.Name, (float)data.SMA);
                    }
                }

                if (minmax != null)
                {
                    minmax.Add(data.SMA);
                }

                data.Count++;
            }
            else
            {
                if (dataDst != null)
                {
                    dataDst.Add(dataSrc[i].X, dataSrc[i].Y, false, dataSrc[i].Index);
                }
            }

            return(data.SMA);
        }
예제 #2
0
        private PlotCollection saveData(string strName, PlotCollection price, Histogram rgHistogram, List <Tuple <float, float, int> > rgTopRanges, float fTop, float fBottom)
        {
            PlotCollection col = new PlotCollection(strName);

            col.Add(rgHistogram.Count);

            for (int i = 0; i < rgHistogram.Count; i++)
            {
                col.Add(rgHistogram[i].ToList());
            }

            col.Add(rgTopRanges.Count);

            for (int i = 0; i < rgTopRanges.Count; i++)
            {
                List <double> rgdf = new List <double>();
                rgdf.Add(rgTopRanges[i].Item1);
                rgdf.Add(rgTopRanges[i].Item2);
                rgdf.Add(rgTopRanges[i].Item3);

                col.Add(rgdf);
            }

            col.Add(price.AbsoluteMinYVal);
            col.Add(price.AbsoluteMinYVal);
            col.Add(fTop);
            col.Add(fBottom);

            return(col);
        }
예제 #3
0
        private void lineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timerData.Enabled  = false;
            toolStrip1.Visible = false;

            List <PlotCollectionSet> rgSet = new List <PlotCollectionSet>();
            int nCount = m_nDataCount;

            for (int i = 0; i < 4; i++)
            {
                PlotCollectionSet set = new PlotCollectionSet();
                PlotCollection    plots;

                plots = new PlotCollection("plot_1 - " + i.ToString());
                for (int j = 0; j < nCount; j++)
                {
                    plots.Add(new Plot(j, j * Math.Sin(j)));
                }

                set.Add(plots);
                plots = new PlotCollection("plot_2 - " + i.ToString());
                for (int j = 0; j < nCount; j++)
                {
                    plots.Add(new Plot(j, j * Math.Sin(j) * Math.Cos(j)));
                }

                set.Add(plots);
                rgSet.Add(set);
            }

            configureLineCharts();

            updateGraph(rgSet);
        }
        public PlotCollectionSet GetLastData(int nLookahead = 0, bool bRemove = false)
        {
            if (m_data.Count == 0)
            {
                return(null);
            }

            if (nLookahead > 0 && bRemove)
            {
                throw new Exception("Removing data is not supported when retrieving data with a lookahead.");
            }

            PlotCollectionSet     lastData = new PlotCollectionSet();
            List <PlotCollection> rgPlots  = new List <PlotCollection>();

            for (int i = 0; i < m_data.Count; i++)
            {
                PlotCollectionSet dataFrame = m_data[i];

                if (dataFrame.Count == 0)
                {
                    return(null);
                }

                PlotCollection plots = new PlotCollection("Frame " + i.ToString());

                for (int j = 0; j < dataFrame.Count; j++)
                {
                    PlotCollection framePlots = dataFrame[j];
                    if (framePlots.Count == 0)
                    {
                        return(null);
                    }

                    Plot last = framePlots[framePlots.Count - (1 + nLookahead)];
                    if (last.Name == null)
                    {
                        last.Name = framePlots.Name;
                    }

                    plots.Add(last);

                    if (bRemove)
                    {
                        framePlots.RemoveAt(framePlots.Count - 1);
                    }
                }

                lastData.Add(plots);
            }

            if (bRemove)
            {
                m_output = m_surface.BuildGraph(m_config, m_data);
                SimpleGraphingControl_Resize(this, EventArgs.Empty);
                ScrollToEnd(false);
            }

            return(lastData);
        }
예제 #5
0
        /// <summary>
        /// Called on each testing iteration of the sequence model.
        /// </summary>
        /// <param name="sender">Specifies the event sender.</param>
        /// <param name="e">Specifies the event args.</param>
        private void m_mycaffe_OnTestingIteration(object sender, TestingIterationArgs <float> e)
        {
            float fAccuracy = m_rgAccuracyTraining.Average();

            m_plotsSequenceAccuracyTrain.Add(m_nTotalSequences, fAccuracy * 100);
            if (m_plotsSequenceAccuracyTrain.Count > 100)
            {
                m_plotsSequenceAccuracyTrain.RemoveAt(0);
            }

            m_rgAccuracyTesting.Add((float)e.Accuracy);
            m_rgAccuracyTesting.RemoveAt(0);
            fAccuracy = m_rgAccuracyTesting.Average();

            m_plotsSequenceAccuracyTest.Add(m_nTotalSequences, fAccuracy * 100);
            if (m_plotsSequenceAccuracyTest.Count > 100)
            {
                m_plotsSequenceAccuracyTest.RemoveAt(0);
            }

            PlotCollectionSet set = new PlotCollectionSet();

            set.Add(m_plotsSequenceAccuracyTrain);
            set.Add(m_plotsSequenceAccuracyTest);

            Image img = SimpleGraphingControl.QuickRender(set, pbImageAccuracy.Width, pbImageAccuracy.Height, false, null, null, false, m_rgZeroLine);

            m_bw.ReportProgress(1, new Tuple <Image, int>(img, 1));
        }
예제 #6
0
        private void stepNext()
        {
            try
            {
                if (m_rgLastData.Count > 0)
                {
                    PlotCollectionSet lastData1 = m_rgLastData[m_rgLastData.Count - 1];
                    m_rgLastData.RemoveAt(m_rgLastData.Count - 1);
                    simpleGraphingControl1.AddData(lastData1, true);
                    return;
                }

                PlotCollectionSet newData  = new PlotCollectionSet();
                PlotCollectionSet lastData = simpleGraphingControl1.GetLastData();
                if (lastData == null)
                {
                    return;
                }

                for (int i = 0; i < lastData.Count; i++)
                {
                    PlotCollection frameData    = lastData[i];
                    PlotCollection frameNewData = new PlotCollection(frameData.Name);

                    for (int j = 0; j < frameData.Count; j++)
                    {
                        double   dfTime  = frameData[j].X;
                        DateTime dtStart = DateTime.FromFileTime((long)dfTime);
                        dtStart += TimeSpan.FromDays(1);
                        dfTime   = dtStart.ToFileTime();

                        double        dfVal   = frameData[j].Y + (-1 + (2 * m_random.NextDouble()));
                        double        dfO     = dfVal;
                        double        dfC     = dfVal + (-1 + (2 * m_random.NextDouble()));
                        double        dfH     = Math.Max(dfO, dfC) + (Math.Abs(dfC - dfO) * m_random.NextDouble());
                        double        dfL     = Math.Min(dfO, dfC) - (Math.Abs(dfC - dfO) * m_random.NextDouble());
                        List <double> rgdfVal = new List <double>()
                        {
                            dfO, dfH, dfL, dfC
                        };

                        Plot p = new Plot(dfTime, rgdfVal);
                        p.Action1Active = enableActionStripMenuItem.Checked;
                        p.Action2Active = enableActionStripMenuItem.Checked;

                        frameNewData.Add(p);
                    }

                    newData.Add(frameNewData);
                }

                simpleGraphingControl1.AddData(newData, true, true);
            }
            finally
            {
            }
        }
        public List <PlotCollectionSet> GetLastOutput(int nSequenceLength = 1)
        {
            List <PlotCollectionSet> rgOutput = new List <PlotCollectionSet>();

            if (m_output == null || m_output.Count == 0)
            {
                return(rgOutput);
            }

            int nCount = m_output[0][0].Count;

            int nStart = nCount - nSequenceLength;

            if (nStart < 0)
            {
                nStart          = 0;
                nSequenceLength = nCount;
            }

            for (int k = nStart; k < nStart + nSequenceLength; k++)
            {
                PlotCollectionSet     lastData = new PlotCollectionSet();
                List <PlotCollection> rgPlots  = new List <PlotCollection>();

                for (int i = 0; i < m_output.Count; i++)
                {
                    PlotCollectionSet dataFrame = m_output[i];

                    if (dataFrame.Count > 0)
                    {
                        PlotCollection plots = new PlotCollection("Frame " + i.ToString());

                        for (int j = 0; j < dataFrame.Count; j++)
                        {
                            PlotCollection framePlots = dataFrame[j];
                            if (framePlots.Count == nCount)
                            {
                                Plot last = framePlots[k];
                                last.Name = framePlots.Name;
                                plots.Add(last);
                            }
                        }

                        lastData.Add(plots);
                    }
                }

                rgOutput.Add(lastData);
            }

            return(rgOutput);
        }
예제 #8
0
        /// <summary>
        /// Event called on each training iterations.
        /// </summary>
        /// <param name="sender">Specifies who sent the event.</param>
        /// <param name="e">Specifies the event parameters.</param>
        private void m_mycaffe_OnTrainingIteration(object sender, TrainingIterationArgs <float> e)
        {
            if (m_swTraining.Elapsed.TotalMilliseconds > 1000)
            {
                Console.WriteLine("Iteration = " + e.Iteration.ToString("N0") + " Loss = " + e.SmoothedLoss.ToString());
                m_swTraining.Restart();
            }

            if (e.Iteration % 30 == 0)
            {
                m_plots.Add(e.Iteration, e.SmoothedLoss);
            }
        }
예제 #9
0
        /// <summary>
        /// Called on each training iteration of the input model used to detect each hand written character.
        /// </summary>
        /// <param name="sender">Specifies the event sender.</param>
        /// <param name="e">Specifies the event args.</param>
        private void m_mycaffeInput_OnTrainingIteration(object sender, TrainingIterationArgs <float> e)
        {
            if (m_sw.Elapsed.TotalMilliseconds > 1000)
            {
                m_log.Progress = e.Iteration / (double)m_model.Iterations;
                m_log.WriteLine("MNIST Iteration " + e.Iteration.ToString() + " of " + m_model.Iterations.ToString() + ", loss = " + e.SmoothedLoss.ToString());
                m_sw.Restart();

                m_plotsInputLoss.Add(e.Iteration, e.SmoothedLoss);
                Image img = SimpleGraphingControl.QuickRender(m_plotsInputLoss, pbImage.Width, pbImage.Height, false, null, null, true, m_rgZeroLine);
                m_bw.ReportProgress(1, img);
            }
        }
예제 #10
0
        private PlotCollection combine(string strName, PlotCollection p1, PlotCollection p2)
        {
            PlotCollection p = new PlotCollection(strName + " high/low");

            if (p1.Count != p2.Count)
            {
                throw new Exception("The two plot collections must have the same number of items!");
            }

            for (int i = 0; i < p1.Count; i++)
            {
                if (p1[i].Active)
                {
                    p.Add(p1[i]);
                }
                else if (p2[i].Active)
                {
                    p.Add(p2[i]);
                }
            }

            return(p);
        }
        public void AddData(PlotCollectionSet data, bool bMaintainCount, bool bRender = false)
        {
            if (data.Count != m_data.Count)
            {
                throw new Exception("The number of plot collections must match the number of plot sets used by the graph.");
            }

            List <string> rgUpdated = new List <string>();

            for (int i = 0; i < data.Count; i++)
            {
                PlotCollectionSet dataFrame = m_data[i];

                if (rgUpdated.Contains(dataFrame[0].Name))
                {
                    continue;
                }

                PlotCollection dataToAdd = data[i];

                if (dataFrame.Count != dataToAdd.Count)
                {
                    throw new Exception("The number of data items to add must match the number of plot collections in the frame!");
                }

                for (int j = 0; j < dataFrame.Count; j++)
                {
                    PlotCollection dataFrameItems = dataFrame[j];
                    Plot           plot           = dataToAdd[j];

                    dataFrameItems.Add(plot);

                    if (bMaintainCount)
                    {
                        dataFrameItems.RemoveAt(0);
                    }
                }

                rgUpdated.Add(dataFrame[0].Name);
            }

            m_output = m_surface.BuildGraph(m_config, m_data);
            SimpleGraphingControl_Resize(this, EventArgs.Empty);
            ScrollToEnd(bRender);
        }
예제 #12
0
        /// <summary>
        /// Create the PlotCollection for display on the graph.
        /// </summary>
        /// <param name="strName">Specifies the name of the plot.</param>
        /// <param name="rgT">Specifies the X axis data (e.g. the time sequence)</param>
        /// <param name="rgrgY">Specifies the Y data.</param>
        /// <param name="nYIdx">Specifies which of the Y data items are to be activated in the plot.</param>
        /// <returns>The filled PlotCollection is returned.</returns>
        private PlotCollection createPlots(string strName, float[] rgT, List <float[]> rgrgY, int nYIdx)
        {
            PlotCollection plots = new PlotCollection();

            plots.Name = strName;

            int nTidx = 0;

            for (int i = 0; i < rgrgY.Count; i++)
            {
                for (int j = 0; j < rgrgY[i].Length; j++)
                {
                    float fX      = rgT[nTidx] * 100;
                    float fY      = rgrgY[i][j];
                    bool  bActive = (i == nYIdx) ? true : false;
                    plots.Add(fX, fY, bActive);
                    nTidx++;
                }
            }

            return(plots);
        }
예제 #13
0
        /// <summary>
        /// Called on each training iteration of the sequence model used to encode each detected hand written character
        /// and then decode the encoding into the proper section of the Sin curve.
        /// </summary>
        /// <param name="sender">Specifies the event sender.</param>
        /// <param name="e">Specifies the event args.</param>
        private void m_mycaffe_OnTrainingIteration(object sender, TrainingIterationArgs <float> e)
        {
            if (m_sw.Elapsed.TotalMilliseconds > 1000)
            {
                m_log.Progress = e.Iteration / (double)m_model.Iterations;
                m_log.WriteLine("Seq2Seq Epoch " + m_nTotalEpochs.ToString() + " Sequence " + m_nTotalSequences.ToString() + " Iteration " + e.Iteration.ToString() + " of " + m_model.Iterations.ToString() + ", loss = " + e.SmoothedLoss.ToString(), true);
                m_sw.Restart();

                m_fTotalCost += (float)e.SmoothedLoss;
                m_nTotalIter1++;
                float fLoss = m_fTotalCost / m_nTotalIter1;

                m_plotsSequenceLoss.Add(m_nTotalSequences, fLoss);
                if (m_plotsSequenceLoss.Count > 2000)
                {
                    m_plotsSequenceLoss.RemoveAt(0);
                }

                Image img = SimpleGraphingControl.QuickRender(m_plotsSequenceLoss, pbImageLoss.Width, pbImageLoss.Height, false, null, null, true, m_rgZeroLine);
                m_bw.ReportProgress(1, new Tuple <Image, int>(img, 0));
            }
        }
예제 #14
0
        /// <summary>
        /// Create a simple moving average of the input plot.
        /// </summary>
        /// <param name="strName">Specifies the name of the new plot.</param>
        /// <param name="plotsSrc">Specifies the source plots.</param>
        /// <param name="nIterations">Specifies the iterations over which to average.</param>
        /// <returns>The plot of average values is returned.</returns>
        private PlotCollection createPlotsAve(string strName, PlotCollection plotsSrc, int nIterations)
        {
            PlotCollection plots = new PlotCollection();

            plots.Name = strName + nIterations.ToString();
            List <float> rgfVal = new List <float>();

            for (int i = 0; i < plotsSrc.Count; i++)
            {
                rgfVal.Add(plotsSrc[i].Y);

                if (rgfVal.Count > nIterations)
                {
                    rgfVal.RemoveAt(0);
                }

                bool   bActive = (rgfVal.Count == nIterations) ? true : false;
                double fAve    = rgfVal.Sum() / nIterations;

                plots.Add(plotsSrc[i].X, fAve, bActive);
            }

            return(plots);
        }
예제 #15
0
        private PlotCollection getLowPoints(PlotCollection data, int nLevel, int nLookahead)
        {
            if (data == null || data.Count < 3)
            {
                return(null);
            }

            PlotCollection dataLow = new PlotCollection(data.Name + " L" + nLevel.ToString());

            int nOpen  = data[0].PrimaryIndexY;
            int nHigh  = data[0].PrimaryIndexY;
            int nLow   = data[0].PrimaryIndexY;
            int nClose = data[0].PrimaryIndexY;

            if (data[0].Y_values.Length == 4)
            {
                nHigh  = 1;
                nLow   = 2;
                nClose = 3;
            }

            List <Tuple <int, Plot> > rgActive = new List <Tuple <int, Plot> >();

            for (int i = 0; i < data.Count - nLookahead; i++)
            {
                if (data[i].Active)
                {
                    rgActive.Add(new Tuple <int, Plot>(i, data[i]));
                }
            }

            if (rgActive.Count < 3)
            {
                return(null);
            }

            MinMax minmax = new MinMax();

            int nIdx = 1;

            for (int i = 0; i < data.Count; i++)
            {
                int nIdxCurrent = rgActive[nIdx].Item1;

                if (i == nIdxCurrent && nIdx < rgActive.Count - 1)
                {
                    Plot plotCurrent = data[nIdxCurrent];
                    int  nIdxPast    = rgActive[nIdx - 1].Item1;
                    Plot plotPast    = data[nIdxPast];
                    int  nIdxFuture  = rgActive[nIdx + 1].Item1;
                    Plot plotFuture  = data[nIdxFuture];

                    double dfOpen  = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nOpen];
                    double dfClose = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nClose];
                    double dfHigh1 = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nHigh];
                    double dfLow1  = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nLow];

                    double dfHigh0 = (plotPast.Y_values.Length == 1) ? plotPast.Y : plotPast.Y_values[nHigh];
                    double dfLow0  = (plotPast.Y_values.Length == 1) ? plotPast.Y : plotPast.Y_values[nLow];

                    double dfHigh2 = (plotFuture.Y_values.Length == 1) ? plotFuture.Y : plotFuture.Y_values[nHigh];
                    double dfLow2  = (plotFuture.Y_values.Length == 1) ? plotFuture.Y : plotFuture.Y_values[nLow];

                    bool bLow = false;

                    if (dfLow1 < dfLow0 && dfLow1 < dfLow2)
                    {
                        bLow = true;
                    }

                    minmax.Add(dfLow1);

                    dataLow.Add(new Plot(data[nIdxCurrent].X, dfLow1, null, bLow, data[nIdxCurrent].Index));
                    nIdx++;
                }
                else
                {
                    double dfLow = (data[i].Y_values.Length == 1) ? data[i].Y : data[i].Y_values[nLow];

                    dataLow.Add(new Plot(data[i].X, dfLow, null, false, data[i].Index));
                }
            }

            dataLow.SetMinMax(minmax);

            return(dataLow);
        }
예제 #16
0
        public double Process(EmaData data, int i, MinMax minmax = null, int nLookahead = 0, bool bAddToParams = false)
        {
            bool bActive = data.SrcData[i].Active;

            PlotCollection dataSrc = data.SrcData;
            PlotCollection dataDst = data.DstData;
            double         dfMult  = data.Multiplier;

            if (i < dataSrc.Count)
            {
                if (data.Index < m_config.Interval)
                {
                    if (bActive)
                    {
                        data.Total += dataSrc[i].Y;
                        data.Index++;
                        if (dataDst != null)
                        {
                            dataDst.Add(dataSrc[i].X, data.Total / (data.Index + 1), false, dataSrc[i].Index);
                        }
                    }
                    else
                    {
                        if (dataDst != null)
                        {
                            dataDst.Add(dataSrc[i].X, dataSrc[i].Y, false, dataSrc[i].Index);
                        }
                    }
                }
                else
                {
                    if (data.EMA == 0)
                    {
                        data.EMA = data.Total / m_config.Interval;
                    }

                    if (i < dataSrc.Count - nLookahead)
                    {
                        data.EMA = (dataSrc[i].Y - data.EMA) * data.Multiplier + data.EMA;
                    }
                    else
                    {
                        bActive = false;
                    }

                    if (dataDst != null)
                    {
                        dataDst.Add(data.EMA, bActive, dataSrc[i].Index);
                    }

                    if (bAddToParams && bActive)
                    {
                        dataSrc[i].SetParameter(dataDst.Name, (float)data.EMA);
                    }

                    if (minmax != null)
                    {
                        minmax.Add(data.EMA);
                    }
                }
            }

            return(data.EMA);
        }
예제 #17
0
        private void candleFromExternalDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialogBin.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            List <PlotCollectionSet> rgSet = new List <PlotCollectionSet>();

            if (Path.GetExtension(openFileDialogBin.FileName).ToLower() == ".bin")
            {
                using (FileStream fs = File.OpenRead(openFileDialogBin.FileName))
                    using (BinaryReader br = new BinaryReader(fs))
                    {
                        byte[] rgBytes = br.ReadBytes((int)fs.Length);
                        rgSet = PlotCollectionSet.LoadList(rgBytes);
                    }
            }
            else
            {
                PlotCollection colPlots = new PlotCollection("Prices");

                using (StreamReader sr = new StreamReader(openFileDialogBin.FileName))
                {
                    string strLine = sr.ReadLine();
                    strLine = sr.ReadLine();

                    while (strLine != null)
                    {
                        string[] rgstr = strLine.Split(',');

                        int      nIdx = 0;
                        DateTime dt;
                        if (!DateTime.TryParse(rgstr[nIdx], out dt))
                        {
                            nIdx++;
                            dt = DateTime.Parse(rgstr[nIdx]);
                        }

                        nIdx++;
                        float fOpen = float.Parse(rgstr[nIdx]);
                        nIdx++;
                        float fHigh = float.Parse(rgstr[nIdx]);
                        nIdx++;
                        float fLow = float.Parse(rgstr[nIdx]);
                        nIdx++;
                        float fClose = float.Parse(rgstr[nIdx]);
                        nIdx++;
                        long lVol = long.Parse(rgstr[nIdx]);

                        colPlots.Add(dt.ToFileTime(), new float[] { fOpen, fHigh, fLow, fClose });
                        colPlots[colPlots.Count - 1].Tag   = dt;
                        colPlots[colPlots.Count - 1].Count = lVol;

                        strLine = sr.ReadLine();
                    }
                }

                PlotCollectionSet set = new PlotCollectionSet();
                set.Add(colPlots);
                rgSet.Add(set);
            }

            while (rgSet.Count < 4)
            {
                rgSet.Add(rgSet[0].Clone());
            }

            configureCandleCharts(false, rgSet, true);

            updateGraph(rgSet);
        }
예제 #18
0
        private void candleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <PlotCollectionSet> rgSet = new List <PlotCollectionSet>();
            int            nCount          = m_nDataCount;
            double         dfInc           = TimeSpan.FromDays(1).TotalMinutes;
            DateTime       dtStart         = DateTime.Today - TimeSpan.FromDays(nCount);
            double         dfTimeStart     = dtStart.ToFileTime();
            PlotCollection plotsLast       = null;
            bool           bEnableOverlay  = false;

            if (sender == candleWithOverlayToolStripMenuItem)
            {
                bEnableOverlay = true;
            }

            for (int i = 0; i < 4; i++)
            {
                PlotCollectionSet set = new PlotCollectionSet();
                PlotCollection    plots;
                double            dfTime = dfTimeStart;
                double            dfVal  = 100;

                if (plotsLast != null)
                {
                    plots = plotsLast;
                }
                else
                {
                    plots = new PlotCollection("plot_1 - " + i.ToString(), int.MaxValue, dfInc);
                    for (int j = 0; j < nCount; j++)
                    {
                        double        dfO     = dfVal;
                        double        dfC     = dfVal + (-1 + (2 * m_random.NextDouble()));
                        double        dfH     = Math.Max(dfO, dfC) + (Math.Abs(dfC - dfO) * m_random.NextDouble());
                        double        dfL     = Math.Min(dfO, dfC) - (Math.Abs(dfC - dfO) * m_random.NextDouble());
                        List <double> rgdfVal = new List <double>()
                        {
                            dfO, dfH, dfL, dfC
                        };
                        long lVol = m_random.Next(10000);

                        Plot p = new Plot(dfTime, rgdfVal, lVol);

                        if (bEnableOverlay)
                        {
                            p.SetParameter("cos", (float)Math.Cos(j));
                        }

                        plots.Add(p);

                        dtStart += TimeSpan.FromMinutes(1);
                        dfTime   = dtStart.ToFileTime();
                        dfVal   += -1 + (2 * m_random.NextDouble());
                    }
                }

                set.Add(plots);
                rgSet.Add(set);

                if (i % 2 == 0)
                {
                    plotsLast = plots;
                }
                else
                {
                    plotsLast = null;
                }
            }

            double         dfSlope;
            double         dfConfWid;
            PlotCollection colReg = rgSet[0][0].CalculateLinearRegressionLines(out dfSlope, out dfConfWid);

            rgSet[0].Add(colReg);

            configureCandleCharts(bEnableOverlay, rgSet, false);

            updateGraph(rgSet);
        }