Overall Statistics
Total Trades
66
Average Win
1.62%
Average Loss
-0.71%
Compounding Annual Return
-6.873%
Drawdown
16.900%
Expectancy
-0.296
Net Profit
-11.738%
Sharpe Ratio
-0.497
Loss Rate
78%
Win Rate
22%
Profit-Loss Ratio
2.27
Alpha
-0.046
Beta
0.007
Annual Standard Deviation
0.091
Annual Variance
0.008
Information Ratio
-1.027
Tracking Error
0.129
Treynor Ratio
-6.596
Total Fees
$0.00
namespace QuantConnect 
{  
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	public string symbol = "EURUSD";
    	SimpleMovingAverage Slow;
    	RollingWindow<bool> Cross;
    	
        public override void Initialize() 
        {
            SetStartDate(2016, 1, 1);         
            SetEndDate(DateTime.Now);
            SetCash(1000);
            
            AddSecurity(SecurityType.Forex, symbol, Resolution.Daily);
            Slow = SMA(symbol, 20);
            
            Cross = new RollingWindow<bool>(5);
        }
        
        public void OnData(QuoteBars data) 
        {
        	var currentPrice = data[symbol].Price;
        	
        	var cross = currentPrice > Slow;
        	Cross.Add(cross);
        	if(!Cross.IsReady) return;
        	
        	if(!Portfolio[symbol].IsLong && Cross[0] && !Cross[1])
        	{
        		SetHoldings(symbol, 2, false, "Long " + symbol);
        	}
        	
        	if(!Portfolio[symbol].IsShort && !Cross[0] && Cross[1])
        	{
        		SetHoldings(symbol, -2, false, "Short " + symbol);
        	}
        	
        }
    }
}