Пример #1
0
        /// <summary>
        /// creates a barlist with array of custom intervals
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="intervals"></param>
        public BarListImpl(string symbol, int[] intervals, BarInterval[] types)
        {            // set symbol
            _sym = symbol;
            // set intervals requested
            _availint = intervals;
            // size length of interval data to # of requested intervals
            _intdata = new IntervalData[_availint.Length];
            // create interval data object for each interval
            for (int i = 0; i < _availint.Length; i++)
            {
                try
                {
                    // save index to this data for the interval
                    _intdataidx.Add(_availint[i], i);
                }
                // if key was already present, already had this interval
                catch (Exception) { continue; }
                // set default interval to first one
                if (i == 0)
                {
                    _defaultint = _availint[0];
                }
                // create data object appropriate for type of interval
                switch (types[i])
                {
                case BarInterval.CustomTicks:
                    _intdata[i] = new TickIntervalData(_availint[i]);
                    break;

                case BarInterval.CustomVol:
                    _intdata[i] = new VolIntervalData(_availint[i]);
                    break;

                default:
                    _intdata[i] = new TimeIntervalData(_availint[i]);
                    break;
                }

                // subscribe to bar events
                _intdata[i].NewBar += new SymBarIntervalDelegate(BarListImpl_NewBar);
            }
        }
Пример #2
0
        /// <summary>
        /// creates a barlist with array of custom intervals
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="intervals"></param>
        public BarListImpl(string symbol, int[] intervals, BarInterval[] types)
        {
            // set symbol
            _sym = symbol;
            // set intervals requested
            _availint = intervals;
            // size length of interval data to # of requested intervals
            _intdata = new IntervalData[_availint.Length];
            // create interval data object for each interval
            for (int i = 0; i < _availint.Length; i++)
            {
                try
                {
                    // save index to this data for the interval
                    _intdataidx.Add(_availint[i], i);
                }
                // if key was already present, already had this interval
                catch (Exception) { continue; }
                // set default interval to first one
                if (i == 0)
                    _defaultint = _availint[0];
                // create data object appropriate for type of interval
                switch (types[i])
                {
                    case BarInterval.CustomTicks:
                        _intdata[i] = new TickIntervalData(_availint[i]);
                        break;
                    case BarInterval.CustomVol:
                        _intdata[i] = new VolIntervalData(_availint[i]);
                        break;
                    default:
                        _intdata[i] = new TimeIntervalData(_availint[i]);
                        break;
                }

                // subscribe to bar events
                _intdata[i].NewBar += new SymBarIntervalDelegate(BarListImpl_NewBar);
            }
        }
Пример #3
0
        /// <summary>
        /// creates a barlist with array of custom intervals
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="custintervals"></param>
        public BarListImpl(string symbol, int[] custintervals, BarInterval[] types)
        {            // set symbol
            _sym = symbol;
            _custintervals = custintervals;
            // set intervals requested
            _intervaltypes = BarInterval2Int(types);
            // size length of interval data to # of requested intervals
            _intdata = new IntervalData[_intervaltypes.Length];
            // index the pairs
            typesize2idx.Clear();
            // create interval data object for each interval
            for (int i = 0; i < _intervaltypes.Length; i++)
            {
                // set default interval to first one
                if (i == 0)
                {
                    _defaultint = _intervaltypes[0];
                    _defaultcustint = _custintervals[0];
                    curintervalidx = 0;
                }

                // save index to this size for the interval
                switch (types[i])
                {
                    case BarInterval.CustomTicks:
                        _intdata[i] = new TickIntervalData(_custintervals[i]);
                        break;
                    case BarInterval.CustomVol:
                        _intdata[i] = new VolIntervalData(_custintervals[i]);
                        break;
                    case BarInterval.CustomTime:
                        _intdata[i] = new TimeIntervalData(_custintervals[i]);
                        break;
                    default:
                        _intdata[i] = new TimeIntervalData(_intervaltypes[i]);
                        break;
                }

            
                // subscribe to bar events
                _intdata[i].NewBar += new SymBarIntervalDelegate(BarListImpl_NewBar);

                // index the pair
                typesize2idx.addindex(_intervaltypes[i].ToString() + _custintervals[i].ToString(), i);
            }
        }