Overall Statistics
namespace QuantConnect 
{   
    public class TimeBasedAlgo : QCAlgorithm
    {
        public override void Initialize() 
        {
            SetStartDate(2017, 1, 1);
            SetEndDate(2018, 1, 1);
            SetCash(5000);
            SetBenchmark("SPY");
            
            SetBrokerageModel(BrokerageName.OandaBrokerage);
            
            AddSecurity(SecurityType.Forex, "EURUSD", Resolution.Tick);
            SetWarmUp(TimeSpan.FromDays(7));
            
			
            
        }
        public override void OnData(Slice data) 
        {
        	
        	var holdings = Portfolio["EURUSD"].Quantity;
        	var sma = SMA("EURUSD", 24, Resolution.Hour);
        	var currentPrice = Securities["EURUSD"].BidPrice;
        	var dayCount = TimeSpan.FromDays(10);    
            var tradeTime = 0;
        	var totalTime = 0;
            bool tradeInPlace = false;
        	
        	if(holdings <= 0)
        	{
        		tradeInPlace = false;
        	}
        	if(holdings > 0)
        	{
        		tradeInPlace = true;
        	}

        	
           if(holdings <= 0 & currentPrice > sma & tradeInPlace == false)
            {
                MarketOrder("EURUSD", 100000);
                LimitOrder("EURUSD", -100000, 20);
                SetHoldings("EURUSD", 1);
                
                Log("Purchased EURUSD on " + Time.ToShortDateString());
            }
            if(holdings <= 0 & currentPrice < sma & tradeInPlace == false)
            {
                MarketOrder("EURUSD", -100000);
                LimitOrder("EURUSD", 100000, 20);
                SetHoldings("EURUSD", 1);
                Log("Sold EURUSD on " + Time.ToShortDateString());
            }
            if (Portfolio["EURUSD"].IsLong && totalTime > 10 )
            {
            	MarketOrder("EURUSD", -100000);
            	List<OrderTicket> cancelledOrders = Transactions.CancelOpenOrders("EURUSD"); 
            	totalTime = 0;
            	SetHoldings("EURUSD", 0);
            	Log("Cancelled All Orders & Closed Long Trade " + Time.ToShortDateString());
            }
            if (Portfolio["EURUSD"].IsShort && totalTime > 10 )
            {
            	MarketOrder("EURUSD", 100000);
            	List<OrderTicket> cancelledOrders = Transactions.CancelOpenOrders("EURUSD");
            	totalTime = 0;
            	SetHoldings("EURUSD", 0);
            	Log("Cancelled All Orders & Closed Short Trade " + Time.ToShortDateString());
            }
            
        }
    }
}