Esempio n. 1
0
        protected override void Test(object param)
        {
            TA.Stoch[] stochs = TA.GetStoch(((List <Candlestick>)param).ToArray(), _lengthK, _lengthD, _lengthSmooth);
            //TA.MACD macd = TA.GetMACD(((List<Candlestick>)param[0]).Select(x => x.close).ToList(), 12, 26);
            //System.IO.StreamWriter sw = new System.IO.StreamWriter("macd.txt");
            //for (int i = 0; i < macd.Macd.Count; i++)
            //{
            //	sw.WriteLine($"{macd.Macd[i]};{macd.Signal[i]};{macd.Histogram[i]}");
            //}
            //sw.Close();
            _D = stochs.Last().stoch_ma;
            _K = stochs.Last().stoch;
            if (_isDTrigger)
            {
                _absoluteAlert.Current = stochs.Last().stoch_ma;
            }
            else
            {
                _absoluteAlert.Current = stochs.Last().stoch;
            }

            if (_absoluteAlert.Test())
            {
                BaseTest(timeframe, _lengthK + _lengthD);
            }

            // used for debuging, always triggers alert
            //_absoluteAlert.Test();
            //BaseTest(timeframe, _lengthK + _lengthD);
        }
Esempio n. 2
0
        protected override void Test(object param)
        {
            TA.MACD macd = TA.GetMACD((from c in (List <Candlestick>) param select c.close).ToList(), _fastLength, _slowLength);
            _MACD      = macd.Macd.Last();
            _signal    = macd.Signal.Last();
            _histogram = macd.Histogram.Last();
            switch (_onType)
            {
            case OnType.MACD: _absoluteAlert1.Current = macd.Macd.Last();
                break;

            case OnType.Signal: _absoluteAlert1.Current = macd.Signal.Last();
                break;

            case OnType.Histogram: _absoluteAlert1.Current = macd.Histogram.Last();
                break;

            case OnType.MACD_Signal:
                _absoluteAlert1.Current = macd.Macd.Last();
                _absoluteAlert2.Current = macd.Signal.Last();
                break;

            case OnType.MACD_Histogram:
                _absoluteAlert1.Current = macd.Macd.Last();
                _absoluteAlert2.Current = macd.Histogram.Last();
                break;

            case OnType.Signal_Histogram:
                _absoluteAlert1.Current = macd.Signal.Last();
                _absoluteAlert2.Current = macd.Histogram.Last();
                break;
            }
            //BaseTest(timeframe, _fastLength > _slowLength ? _fastLength + 10 : _slowLength + 10);//////////////////////////////////////////////
            if ((int)_onType > 2 && _absoluteAlert1.Type == TriggerType.crossing)
            {
                if (_absoluteAlert1.Test(_absoluteAlert2))
                {
                    BaseTest(timeframe, _fastLength > _slowLength ? _fastLength + 10 : _slowLength + 10);
                }
            }
            else if ((int)_onType > 2)
            {
                if (_absoluteAlert1.Test() && _absoluteAlert2.Test())
                {
                    BaseTest(timeframe, _fastLength > _slowLength ? _fastLength + 10 : _slowLength + 10);
                }
            }
            else
            {
                if (_absoluteAlert1.Test())
                {
                    BaseTest(timeframe, _fastLength > _slowLength ? _fastLength + 10 : _slowLength + 10);
                }
            }
        }
Esempio n. 3
0
        protected override void Test(object param)
        {
            //System.IO.StreamWriter sw2 = new System.IO.StreamWriter("rsi.txt");
            //foreach (var c in (List<Candlestick>)param)
            //{
            //	sw2.WriteLine(c.close);
            //}
            //sw2.Close();
            //List<float> r = TA.GetRSI((from c in (List<Candlestick>)param select c.close).ToList(), _length);
            //for (int i = 0; i < r.Count; i++)
            //{
            //}

            switch (_source)
            {
            case Source.open:
                _absoluteAlert.Current = TA.GetRSI((from c in (List <Candlestick>) param select c.open).ToList(), _length).Last();
                break;

            case Source.high:
                _absoluteAlert.Current = TA.GetRSI((from c in (List <Candlestick>) param select c.high).ToList(), _length).Last();
                break;

            case Source.low:
                _absoluteAlert.Current = TA.GetRSI((from c in (List <Candlestick>) param select c.low).ToList(), _length).Last();
                break;

            case Source.close:
                _absoluteAlert.Current = TA.GetRSI((from c in (List <Candlestick>) param select c.close).ToList(), _length).Last();
                break;
            }
            if (_absoluteAlert.Test())
            {
                BaseTest(timeframe, _length);
            }
        }