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 MathNet.Numerics.Statistics;
using QuantConnect.Orders.Slippage;
using System.Text;

namespace QuantConnect 
{   
    public class MultiFeedTest : QCAlgorithm
    {
    	const string _symbol = "AAPL";
    	RollingWindow<DataObject> _datawindows;
    	
        public override void Initialize() 
        {
            SetStartDate(2015, 1, 1);         
            SetEndDate(2015, 2, 1);
            SetCash(5000);
            SetWarmup(4);
            
            AddSecurity(SecurityType.Equity, _symbol, Resolution.Daily);
            
            _datawindows = new RollingWindow<DataObject>(3);
        }

        public void OnData(TradeBars bars) 
        {   
            try
            {
				if (UpdateRollingWindows(bars))
				{
					ConductTradingLogic();
				}
				else
				{
					throw new System.Exception("ERROR in OnData(): No data in bars!");
				}
            }
            catch (Exception ex)
            {
                Log("ERROR in OnData(): " + ex.Message + "\r\n\r\n" + ex.StackTrace);
            }
        	
        }
        
        public bool UpdateRollingWindows(TradeBars bars)
        {
            TradeBar bar = null;
            bars.TryGetValue(_symbol, out bar);
            
            if (bar != null)
            {
            	DataObject dataobject = new DataObject(bar.Open, bar.Close, bar.High, bar.Low);
            	_datawindows.Add(dataobject);
            	Log(String.Format("NEW ITEM ADDED.\tOpen: {0:0.00}\tClose: {1:0.00}\tHigh: {2:0.00}\tLow: {3:0.00}", dataobject.Open, dataobject.Close, dataobject.High, dataobject.Low));
            	
            	return true;
            }
            else
            {
            	return false;
            }
        }
        
        public void ConductTradingLogic()
        {
        	if (_datawindows.IsReady)
        	{
        		bool overallchecks = CheckOne() && CheckTwo() && CheckThree();
        		
        		Log(String.Format("OVERALL: {0}\tCHECK1: {1}\tCHECK2: {2}\tCHECK3: {3}", overallchecks.ToString(), CheckOne().ToString(), CheckTwo().ToString(), CheckThree().ToString()));
        		
        		if (CheckOne() && CheckTwo() &&	CheckThree())
        		{
        			SetHoldings(_symbol, 1.0m);
        		}
        		else
        		{
        			SetHoldings(_symbol, 0.0m);
        		}
        	}
        }
        
        public bool CheckOne()
        {
        	if (_datawindows[1].High < _datawindows[2].High)
        	{
        		return true;
        	}
        	else
        	{
        		return false;
        	}
        }
        
        public bool CheckTwo()
        {
        	if(_datawindows[1].Low > _datawindows[2].Low)
        	{
        		return true;
        	}
        	else
        	{
        		return false;
        	}
        }
        
        public bool CheckThree()
        {
        	if(_datawindows[0].Close > _datawindows[2].High)
        	{
        		return true;
        	}
        	else
        	{
        		return false;
        	}
        }
    }
}
namespace QuantConnect
{
    public class DataObject
    {
        private decimal _open;
        private decimal _close;
        private decimal _high;
        private decimal _low;

        public decimal Open
        {
            get { return _open; }
            set
            {
                _open = value;
            }
        }

        public decimal Close
        {
            get { return _close; }
            set
            {
                _close = value;
            }
        }
        
        public decimal High
        {
            get { return _high; }
            set
            {
                _high = value;
            }
        }
        
    	public decimal Low
        {
            get { return _low; }
            set
            {
                _low = value;
            }
        }
        
        public DataObject(decimal open, decimal close, decimal high, decimal low)
        {
        	Open = open;
        	Close = close;
        	High = high;
        	Low = low;
        }
    }
}