Esempio n. 1
0
        // constructor, called only once, setup multiple tick variables
        public oIndicatorDump(int pPeriods)
        {
            iPeriods = pPeriods;

            ATR         = new iATR(pPeriods);
            BB          = new iBollingerBands(iPeriods, -1);
            CCI         = new iCCI(iPeriods);
            Derivatives = new iDerivatives();
            EMA         = new iEMA(iPeriods);
            FMA         = new iFMA(iPeriods);
            HMA         = new iHMA(iPeriods);
            MACD        = new iMACD(12, 26, 9);
            Momemtum    = new iMomemtum(iPeriods);
            RSI         = new iRSI(iPeriods);
            Renko       = new iRenko(iPeriods);
            SMA         = new iSMA(iPeriods);
            STARCBands  = new iSTARCBands(iPeriods, 2);
            STDDEV      = new iSTDDEV(iPeriods);
            Slope       = new iSlope();
            StochRSI    = new iStochRSI(iPeriods);
            Stochastics = new iStochastics(3, 2, 1);
            Stub        = new iStub(iPeriods);
            Trend       = new iTrend(iPeriods);
            TrueRange   = new iTrueRange();
            WMA         = new iWMA(iPeriods);
        }
        public void RecordMACD(KLine _curKL ,ref iEMA ema11 ,ref iEMA ema22 ,ref iMACD macd )
        {
            ema11.ReceiveTick(_curKL.close);
            ema22.ReceiveTick(_curKL.close);

            double DI = ((double)_curKL.close * 2 + _curKL.highest + _curKL.lowest) / 4.0;
            macd.ReceiveTick(DI / 100);
        }
        public bool ReceiveData(ref int cnt , ref KLine _KL , ref List<KLine> _lst ,
             ref iEMA _ema11, ref iEMA _ema22, ref iMACD _macd ,
             int period , DateTime _CurTime ,
             int open , int highest , int lowest , int close , int amount)
        {
            cnt++;
            if (cnt == 1)
            {
                _KL = new KLine(FIFTEEN_MINUTES, _CurTime, open, highest, lowest, close, amount);
            }
            else
            {
                _KL.amount += amount;
                if (lowest < _KL.lowest)
                    _KL.lowest = lowest;
                else if (highest > _KL.highest)
                    _KL.highest = highest;

                if (cnt == period / ONE_MINUTE)
                {
                    _KL.close = close;
                    _KL.datetime = g_CurTime;
                    _lst.Add(_KL);
                    cnt = 0;

                    //記錄MACD
                    RecordMACD(_KL, ref _ema11, ref _ema22, ref _macd);

                    //K棒收集完成
                    return true;
                }
            }
            return false;
        }