Overall Statistics
using System;
using System.Globalization;
using QuantConnect.Data;
using QuantConnect.Data.Market;

namespace QuantConnect.Algorithm.CSharp
{ 
    public class CandlestickTradeBar5minESData1 : QCAlgorithm
    {
        private string _symbol = "ES";                
        
        public override void Initialize()
        {
            SetStartDate(2016, 01, 04);  //Set Start Date
            SetEndDate(2016, 01, 04);    //Set End Date
            SetCash(100000);             //Set Strategy Cash

            AddData<ES5minData>(_symbol);                               
        }
        
        public void OnData(ES5minData data) 
        {
            if (data.Time.TimeOfDay == new TimeSpan(09, 45, 00))
            {
                Debug(data.Time + "; Open = " + data.Open + "; Close = " + data.Close);
            }
            if (data.Time.TimeOfDay == new TimeSpan(10, 45, 00))
            {
                Debug(data.Time + "; Open = " + data.Open + "; Close = " + data.Close);
            }
            if (data.Time.TimeOfDay == new TimeSpan(12, 45, 00))
            {
                Debug(data.Time + "; Open = " + data.Open + "; Close = " + data.Close);
            }
        }
    }

    public class ES5minData : TradeBar
    {
        public decimal UpperShadow { get; set; }
        public decimal LowerShadow { get; set; }
        public decimal HighLow { get; set; }
        public decimal RealBody { get; set; }
        public decimal UpperShadowPercent { get; set; }
        public decimal LowerShadowPercent { get; set; }

        public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
        {
            return new SubscriptionDataSource("https://www.dropbox.com/s/nybrjl87y877flp/ES%202016-01-04%20-%202016-12-19%20-%20EST.csv?dl=1", SubscriptionTransportMedium.RemoteFile);
        }

        public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
        {
            ES5minData cmBar = new ES5minData();

            try
            {
                var data = line.Split(',');
                //Required.
                cmBar.Symbol = "ES";

                cmBar.Time = DateTime.ParseExact(data[0] + data[1], "yyyyMMddhhmmss", CultureInfo.InvariantCulture);
                
                cmBar.Open = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
                cmBar.High = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
                cmBar.Low = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture);
                cmBar.Close = Convert.ToDecimal(data[5], CultureInfo.InvariantCulture);
                cmBar.Volume = Convert.ToInt64(data[6], CultureInfo.InvariantCulture);
                
                cmBar.Value = cmBar.Close;

                if (cmBar.Close > cmBar.Open)
                {
                    cmBar.UpperShadow = (cmBar.High - cmBar.Close);
                    cmBar.LowerShadow = (cmBar.Open - cmBar.Low);
                    cmBar.RealBody = (cmBar.Close - cmBar.Open);                                     
                }
                else
                {
                    cmBar.UpperShadow = (cmBar.High - cmBar.Open);
                    cmBar.LowerShadow = (cmBar.Close - cmBar.Low);
                    cmBar.RealBody = (cmBar.Open - cmBar.Close);
                }
                cmBar.HighLow = (cmBar.High - cmBar.Low);

                cmBar.UpperShadowPercent = (cmBar.UpperShadow / cmBar.HighLow * 100);
                cmBar.LowerShadowPercent = (cmBar.LowerShadow / cmBar.HighLow * 100);                    
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            return cmBar;
        }
    }
}