Overall Statistics
namespace QuantConnect.Algorithm.CSharp
{	
    public class ParticleMultidimensionalEngine : QCAlgorithm
    {
		private RenkoConsolidator renkoConsolidator;
		private FuturesContract frontmonthContract;
        public override void Initialize()
        {
            SetStartDate(2019, 9, 3);  //Set Start Date
            SetEndDate(2019, 12, 3);
            SetCash(100000);             //Set Strategy Cash
            
            // Subscribe to gold futures chain
            var gc = AddFuture(Futures.Metals.Gold);
            // Filter contracts to only front month contract
            gc.SetFilter(universe => universe.FrontMonth());
            
            // Define the Renko consolidator
            renkoConsolidator = new RenkoConsolidator(10);
            // Set DataConsolidated event handler for the Renko Consolidator
            renkoConsolidator.DataConsolidated += (sender, bar) => {
            	Debug($"Renko Bar Consolidated On {bar.EndTime} for {bar}");
            };
            

        }

        public override void OnData(Slice data)
        {
        	foreach(var chain in data.FutureChains){
        		// Get trade bars for contracts in chain
        		var tradebars = chain.Value.TradeBars;
        		// Get front month contract
        		var contract = chain.Value.FirstOrDefault();
        		
        		// If front month contract has been delisted/updated
        		if(frontmonthContract == null || (contract.Symbol != frontmonthContract.Symbol)){
        			frontmonthContract = contract;
        		}
        		
        		// Get symbol for front month contract
        		var symbol = frontmonthContract.Symbol;
        		
        		// Update Renko Consolidator with trade bar data
        		if(tradebars.Keys.Contains(symbol)){
        			var tradebar = tradebars[symbol];
        			renkoConsolidator.Update(tradebar);
        		}
        		
        		
        	}
        }

    }
}