Ejemplo n.º 1
0
        public override void Compute(StockData aStockData)
        {
            List <MacdPoint> nMacds = TAUtil.MACD(aStockData, 12, 26, 9);

            MacdPoint nPrevMacd = nMacds[nMacds.Count - 2];
            MacdPoint nCurMacd  = nMacds[nMacds.Count - 1];

            double nPrevMacdLine = nPrevMacd.Macd;
            double nCurMacLine   = nCurMacd.Macd;


            if ((nPrevMacdLine > 0) &&
                (nCurMacLine < 0))
            {
                this.Score  = 1;
                this.Signal = true;
            }
        }
Ejemplo n.º 2
0
        public override void Compute(StockData aStockData)
        {
            List <MacdPoint> nMacds = TAUtil.MACD(aStockData, 12, 26, 9);

            MacdPoint nPrevMacd4 = nMacds[nMacds.Count - 5];
            MacdPoint nPrevMacd3 = nMacds[nMacds.Count - 4];
            MacdPoint nPrevMacd2 = nMacds[nMacds.Count - 3];
            MacdPoint nPrevMacd1 = nMacds[nMacds.Count - 2];
            MacdPoint nCurMacd   = nMacds[nMacds.Count - 1];

            if ((nPrevMacd4.Bullish == 0) &&
                (nPrevMacd3.Bullish == 0) &&
                (nPrevMacd2.Bullish == 0) &&
                (nPrevMacd1.Bullish == 0) &&
                (nCurMacd.Bullish == 1))
            {
                this.Score  = 1;
                this.Signal = true;
            }
        }
Ejemplo n.º 3
0
        public static List <MacdPoint> MACD(StockData aStock, int aFastPeriod, int aSlowPeriod, int aSignalPeriod)
        {
            int nStartIndex = 0;
            int nEndIndex   = aStock.DataPoints.Count - 1;

            double[] nInReal = getCloseValues(aStock);
            int      nOutBegIdx;
            int      nOutNBElement;

            double[] nOutMACD       = new double[nEndIndex - nStartIndex + 1];
            double[] nOutMACDSignal = new double[nEndIndex - nStartIndex + 1];
            double[] nOutMACDHist   = new double[nEndIndex - nStartIndex + 1];

            TicTacTec.TA.Library.Core.Macd(nStartIndex, nEndIndex, nInReal, aFastPeriod, aSlowPeriod, aSignalPeriod, out nOutBegIdx, out nOutNBElement, nOutMACD, nOutMACDSignal, nOutMACDHist);

            List <MacdPoint> nOutput = new List <MacdPoint>();

            for (int j = 0; j < nOutBegIdx; j++)
            {
                nOutput.Add(new MacdPoint());
            }

            for (int i = nStartIndex; i < nEndIndex - nStartIndex + 1 - nOutBegIdx; i++)
            {
                MacdPoint nMacdPt = new MacdPoint();
                nMacdPt.Index         = i;
                nMacdPt.Macd          = nOutMACD[i];
                nMacdPt.Signal        = nOutMACDSignal[i];
                nMacdPt.MacdHistogram = nOutMACDHist[i];
                if (i > 0)
                {
                    nMacdPt.Bullish = (nOutMACDHist[i] > nOutMACDHist[i - 1]) ? 1 : 0;
                }
                nOutput.Add(nMacdPt);
            }
            return(nOutput);
        }