Overall Statistics
Total Trades
21
Average Win
21.54%
Average Loss
-1.79%
Compounding Annual Return
246.381%
Drawdown
24.700%
Expectancy
8.109
Net Profit
247.562%
Sharpe Ratio
2.488
Loss Rate
30%
Win Rate
70%
Profit-Loss Ratio
12.01
Alpha
-0.03
Beta
69.214
Annual Standard Deviation
0.371
Annual Variance
0.138
Information Ratio
2.45
Tracking Error
0.371
Treynor Ratio
0.013
Total Fees
$77.60
namespace QuantConnect
{
	/*
	This algo uses a Momersion indicator and buys when Momersion is below 45
	and sells when momersion is above 55
	*/
	
    public class Momersion : QCAlgorithm
    {
    	// USER VARIABLES
    	private string ticker = "ETHUSD";    // virtual pair - tracks the current USD value of 1 ether
		private int startingCash = 2000;
		private int maxPosition = 1000;
		private int minPosition = 500;
		
		public int top = 70;
		public int bottom = 30;
		
		private int minPeriod = 12;
		private int fullPeriod = 26;
		
		// PROGRAM VARIABLES
		public decimal price; 
		public decimal holding;   // the number of ether that we hold in the portfolio
		public string baseSymbol;   // "ETH"
		public decimal usd;
		
		MomersionIndicator momersion;
		
		// INITIALIZE BLOCK
        public override void Initialize()
        {
            SetStartDate(2017, 1, 1);  // Set Start Date
            SetEndDate(2018, 1, 1);    // Set End Date
            SetCash(startingCash);    // Set Strategy Cash

            var crypto = AddCrypto(ticker, Resolution.Hour);
            baseSymbol = crypto.BaseCurrencySymbol;
            
			SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash);
			
			momersion = MOMERSION(ticker, minPeriod, fullPeriod, Resolution.Hour);
			
			Chart tradePlotter = new Chart("Trades");
			tradePlotter.AddSeries(new Series("BUY", SeriesType.Scatter, index:0));
			tradePlotter.AddSeries(new Series("SELL", SeriesType.Scatter, index:0));
			AddChart(tradePlotter);
        }

		// ONDATA BLOCK
        public override void OnData(Slice data)
        {
        	price = data[ticker].Price;
        	usd = Portfolio.CashBook["USD"].Amount;
        	
            if (!Portfolio.Invested && usd > minPosition)
            {
                if(momersion < bottom)
                {
                	decimal quantity = Math.Round(Math.Min(usd, maxPosition) / price, 2);
                	MarketOrder(ticker, quantity);
                	Plot("Trades", "BUY", price);
                }
            }
            
            if(Portfolio.Invested)
            {
            	holding = Portfolio.CashBook[baseSymbol].Amount;
            	
            	if(momersion > top)
            	{
            		Sell(ticker, holding);
            		Plot("Trades", "SELL", price);
            	}
            }
        }
    }
}