Esempio n. 1
0
        public override void Update(double dataPoint)
        {
            if (_previousData != 0.0)
            {
                //var gain = dataPoint;
                var profitRatio = (dataPoint - _previousData) / _previousData;
                _stddev.Update(profitRatio);

                SetValue(_stddev.Value);
            }

            _previousData = dataPoint;
        }
Esempio n. 2
0
        public override void Update(double dataPoint)
        {
            _ma.Update(dataPoint);
            var ma = _ma.Value;

            _sd.Update(dataPoint);
            var stddev = _sd.Value;

            var upperBound = ma + _alpha * stddev;
            var lowerBound = ma - _alpha * stddev;

            SetValue(upperBound, ma, lowerBound);
        }
Esempio n. 3
0
        public override void Update(Bar bar)
        {
            var trueRange =
                Math.Max(
                    Math.Max(bar.HighestPrice - bar.LowestPrice, bar.HighestPrice - _prevClosePrice),
                    _prevClosePrice - bar.LowestPrice);

            _prevClosePrice = bar.ClosePrice;

            _sdTrueRange.Update(trueRange);

            var sdtr = _sdTrueRange.Value;

            SetValue(sdtr);
        }
Esempio n. 4
0
        public override void Update(double dataPoint)
        {
            if (_previousData != 0.0)
            {
                //var gain = dataPoint;
                var profitRatio = (dataPoint - _previousData) / _previousData;
                _stddev.Update(profitRatio);
                _movingAverage.Update(profitRatio);

                if (Math.Abs(_movingAverage.Value) < 1e-6)
                {
                    SetValue(_stddev.Value / 0.0001);
                }
                else
                {
                    SetValue(_stddev.Value / Math.Abs(_movingAverage.Value));
                }
            }

            _previousData = dataPoint;
        }