コード例 #1
0
        private DayBar CreateDayBar(HitTicker hitTicker)
        {
            var dayBar = new DayBar(hitTicker.Symbol, hitTicker.Timestamp);

            if (hitTicker.Last.HasValue && hitTicker.Open.HasValue)
            {
                dayBar.Change           = (double)(hitTicker.Last - hitTicker.Open);
                dayBar.ChangePercentage = (double)((hitTicker.Last - hitTicker.Open) / hitTicker.Open) * 100;
                dayBar.Open             = (double)hitTicker.Open;
            }

            if (hitTicker.High.HasValue)
            {
                dayBar.High = (double)hitTicker.High;
            }

            if (hitTicker.Low.HasValue)
            {
                dayBar.Low = (double)hitTicker.Low;
            }

            if (hitTicker.Volume.HasValue)
            {
                dayBar.Volume = (double)hitTicker.Volume;
            }

            return(dayBar);
        }
コード例 #2
0
        private static void Symbol_NewDayBar(Symbol symbol, DayBar dayBar)
        {
            // Get data from day bar
            double open      = dayBar.Open;
            double high      = dayBar.High;
            double low       = dayBar.Low;
            double prevClose = dayBar.PreviousClose;

            // Or get data from symbol object
            open      = symbol.Open;
            high      = symbol.High;
            low       = symbol.Low;
            prevClose = symbol.PrevClose;
        }