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
namespace QuantConnect.Algorithm.CSharp

{

    public class BasicTemplateFuturesConsolidationAlgorithm : QCAlgorithm

    {
        private WilliamsPercentR _willr;
        const decimal stop_loss = 0.25m;
        const decimal take_profit = 0.50m;
        // private decimal new_SL = 0.0m ;
        // private decimal new_TP = 0.0m ;
        // int quantity = 1;
        // int count = 0;
        // int loss= 0 ;
		TradeBar _spyMinutes;
    	// Tradebar  quoteBar; 
    	
        private const string RootSP500 = Futures.Indices.SP500EMini;
		
        public Symbol _symbol= QuantConnect.Symbol.Create(RootSP500, SecurityType.Future, Market.USA);

        private HashSet<Symbol> _futureContracts = new HashSet<Symbol>();


        public override void Initialize()

        {

            SetStartDate(2013, 10, 8);

            SetEndDate(2013, 10, 11);

            SetCash(25000)		;


			
            var futureSP500 = AddFuture(RootSP500);
            
           

            futureSP500.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(91));
 


            SetBenchmark(x => 0);

        }



        public override void OnData(Slice slice)

        {
            foreach (var chain in slice.FutureChains)
			    
            {	
            	
                foreach (var contract in chain.Value)
		
                {
                    if (!_futureContracts.Contains(contract.Symbol))
			
                    {

                        _futureContracts.Add(contract.Symbol);
			
                        var consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(5));


                        SubscriptionManager.AddConsolidator(contract.Symbol, consolidator);
					
                        consolidator.DataConsolidated += OnDataConsolidated;
                        Log("Added new consolidator for " + contract.Symbol.Value);
 
                    }

                }

            }

        }



        private void OnDataConsolidated(object sender, TradeBar quoteBar)

        {
			// decimal price  = quoteBar; 
			
            Log("OnDataConsolidated called");

            Log(quoteBar.ToString());
        }
        
        /*
        
		public void OnData (TradeBars data) {

            if (Time.Hour <= 9 || Time.Hour > 14) return;
			
            TradeBar SPY = data[_symbol];
            decimal price = data[_symbol].Close;
			
            if (!Portfolio.HoldStock) {
                Scan4Entry (SPY);
                return;
            	}
			if (Portfolio.HoldStock) {
                Scan4Exit (SPY);
                return;
            	}	
            // var symbo orderEvent.Symbol;   	
        }

        
        */
        
        
    }

}