Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
using System.Drawing;

namespace QuantConnect.Algorithm.CSharp
{
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	string pair = "GBPUSD";
        
        TimeZoneInfo USlocalZone = TimeZoneInfo.FindSystemTimeZoneById("US/Eastern");
        TimeZoneInfo UKlocalZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/London");
        
        Dictionary<string, CustomHourlyConsolidator> hourly_consolidator_dict = new Dictionary<string, CustomHourlyConsolidator>();

        public override void Initialize()
        {
            SetStartDate(2018, 3, 4);  
            SetEndDate(2018, 3, 30);   
            SetCash(100000);           
           
			AddForex(pair, Resolution.Second, Market.FXCM);
            
            var hourlyConsolidator = new CustomHourlyConsolidator();
			hourly_consolidator_dict[pair] = hourlyConsolidator;
			hourly_consolidator_dict[pair].DataConsolidated += HourlyBarHandler;
			SubscriptionManager.AddConsolidator(pair, hourly_consolidator_dict[pair]);
            
			Chart chart = new Chart("chart");
    		chart.AddSeries(new Series("no DST", SeriesType.Scatter, "", Color.Blue));
    		chart.AddSeries(new Series("NY DST", SeriesType.Scatter, "", Color.Green));
    		chart.AddSeries(new Series("both DST", SeriesType.Scatter, "", Color.Red));
    		AddChart(chart);

        }

       	public override void OnData(Slice data)
        {
    		
			
        }
        
        public void HourlyBarHandler(object sender, QuoteBar consolidated)
        {
    		DateTime f = consolidated.Time;
    	   	DateTime f2 = TimeZoneInfo.ConvertTime(f, USlocalZone);
    	   	DateTime f3 = TimeZoneInfo.ConvertTime(f, UKlocalZone);
    		
    		if (consolidated.Time.Hour == 1)
    		{
        		Log("3 am");
        		
        		if (!USlocalZone.IsDaylightSavingTime(f2)
				&&	!UKlocalZone.IsDaylightSavingTime(f3))
					Plot("chart", "no DST", consolidated.Value);
			
				if (USlocalZone.IsDaylightSavingTime(f2)
				&&	!UKlocalZone.IsDaylightSavingTime(f3))
					Plot("chart", "NY  DST", consolidated.Value);
			
				if (USlocalZone.IsDaylightSavingTime(f2)
				&&	UKlocalZone.IsDaylightSavingTime(f3))
					Plot("chart", "both DST", consolidated.Value);
    		}
        }
        
    }
    
    public class CustomHourlyConsolidator : QuoteBarConsolidator
    {
    	private QuoteBar _consolidatedBar;
    	private static Int32 integ;
    	    
    	public CustomHourlyConsolidator() : base(integ)
    	{
    		_consolidatedBar = new QuoteBar();
    	}
    	 
    	public override Type OutputType
    	{
    		get { return typeof (QuoteBar); }
    	}
    	 
    	 
	   	public override void Update(QuoteBar data)
    	{
    		if (data == null)
    			return;
    			
    		if (data.Time.Minute == 59 && data.Time.Second == 59)
    		{
    			_consolidatedBar.Update(data.Close, data.Bid.Close, data.Ask.Close, 0, data.LastBidSize, data.LastAskSize);
    			OnDataConsolidated(_consolidatedBar);
    	        _consolidatedBar = new QuoteBar
    	        	{
    	            	Time = data.Time,
    	            	Symbol = data.Symbol
    	           	};
    		}
    		else
    	    	_consolidatedBar.Update(data.Close, data.Bid.Close, data.Ask.Close, 0, data.LastBidSize, data.LastAskSize);
    	    	
    	}
    }

}