Ejemplo n.º 1
0
        public PlotCollectionSet GetData(PlotCollectionSet dataset, int nDataIdx, int nLookahead, Guid?guid = null, bool bAddToParams = false)
        {
            SmaData data = GetSmaData(dataset, nDataIdx, nLookahead, bAddToParams);

            return(new PlotCollectionSet(new List <PlotCollection>()
            {
                data.DstData
            }));
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public SmaData GetSmaData(PlotCollectionSet dataset, int nDataIdx, int nLookahead = 0, bool bAddToParams = false)
        {
            SmaData data   = Pre(dataset, nDataIdx);
            MinMax  minmax = new MinMax();

            for (int i = 0; i < data.SrcData.Count; i++)
            {
                Process(data, i, minmax, nLookahead, bAddToParams);
            }

            data.DstData.SetMinMax(minmax);

            return(data);
        }