Overall Statistics
Total Trades
466
Average Win
0.90%
Average Loss
-0.91%
Compounding Annual Return
-100.000%
Drawdown
55.900%
Expectancy
-0.330
Net Profit
-50.851%
Sharpe Ratio
-12.24
Loss Rate
66%
Win Rate
34%
Profit-Loss Ratio
0.99
Alpha
-8.452
Beta
9.071
Annual Standard Deviation
0.772
Annual Variance
0.596
Information Ratio
-12.556
Tracking Error
0.744
Treynor Ratio
-1.042
Total Fees
$0.00
namespace QuantConnect.MAAlgorithm
{
    public class MAAlgorithm : QCAlgorithm
    {
    	RollingWindow<TradeBar> _window1 = new RollingWindow<TradeBar>(2);
        public string[] Symbols = {"EURUSD","NZDUSD","AUDUSD","USDCAD"};

        private ExponentialMovingAverage fast;
        private ExponentialMovingAverage slow;

        public override void Initialize()
        {
            SetStartDate(2017, 04, 01);
            SetEndDate(2017, 04, 20);
			SetCash(1000);
		foreach (var symbol in Symbols)
            {
            SetBrokerageModel(BrokerageName.OandaBrokerage);
            AddSecurity(SecurityType.Forex, symbol, Resolution.Hour);
            Securities[symbol].FeeModel = new ConstantFeeModel(0);
            
            fast = EMA(symbol, 13, Resolution.Hour);
            slow = EMA(symbol, 48, Resolution.Hour);
            }
        }
        
        public void OnData(TradeBars data)
        {
        	foreach (var symbol in Symbols)
        	{
        			
        			var holdingsL = Portfolio[symbol].IsLong;
        			var holdingsS = Portfolio[symbol].IsShort;
        			var currentHigh = data[symbol].High;
        			var currentLow = data[symbol].Low;
        			var quantity = (10000);
        			
        			_window1.Add(data[symbol]);
        		 	if (!_window1.IsReady) return;
            		var previousLow = _window1[1].Low;
            		var previousHigh = _window1[1].High;
        	
            		if (!holdingsL && fast>slow)
        			{
                	Log("Long  " + Securities[symbol] + "  at  " + Securities[symbol].Price);
                    MarketOrder(symbol, quantity);
                	}
                	
                	if (holdingsL && ((currentLow<previousLow)||(fast<slow)))
                	{
                	Log("Sold  " + Securities[symbol] + "  at  " + Securities[symbol].Price);
                	Liquidate(symbol);
                	}
            		
                	if (!holdingsS && fast<slow)
            		{
                	Log("Short  " + Securities[symbol] + "  at  " + Securities[symbol].Price);
                	MarketOrder(symbol, -quantity);
                	}
                	
                	if (holdingsS && ((currentHigh>previousHigh)||(fast>slow)))
                	{
                	Log("Covered  " + Securities[symbol] + "  at  " + Securities[symbol].Price);
                	Liquidate(symbol);
                	}
        	}
    	}
    }
}