Overall Statistics
namespace QuantConnect 
{   
   
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    
    	private MovingAverageConvergenceDivergence _macd;
		private mySlope Slope45;
	   	public readonly IReadOnlyList<string> EquitySymbols = new List<string>
        {
            "AAPL", "SPY"
        };
    	
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize() 
        {
			
            SetStartDate(2018, 01 ,01);
            SetEndDate(2018, 5, 17);
            
            foreach (var symbol in EquitySymbols)
            {
                AddSecurity(SecurityType.Equity, symbol, Resolution.Daily);
                Slope45 = new mySlope(45);
                RegisterIndicator(symbol, Slope45, Resolution.Daily, Field.Close);
                _macd = MACD(symbol, 12, 26, 9, MovingAverageType.Exponential, Resolution.Daily);
            }
        }

        
        public void OnData(TradeBars data) 
        {
        	if (!_macd.IsReady) return;
			if (!Slope45.IsReady  ) return; 
			
        	foreach(var security in Securities.Values)
        	{
        		Debug (String.Format(" {0} {1} slope: {2:0.000} macd: {3:0.000}",Time.ToShortDateString(), 
        		security.Symbol, Slope45, _macd));
        	   
        	}
	  }
	}
}
using MathNet.Numerics;

namespace QuantConnect
{
	public class mySlope : WindowIndicator<IndicatorDataPoint>
    {
    	
    	private int _days;
    	private int _dayCounter;
    	
    	private List<double> _xValues;
    	private List<double> _yValues;
    	
        public mySlope(int period)
            : base("Slope1" + period, period)
        {
        	
        	//_days = period - 1;
        	_days = period;
        	_dayCounter = 0;
        	_xValues = new List<double>();
        	_yValues = new List<double>();
        }

        /*public mySlope(string name, int period)
            : base(name, period)
        {
        	
        }
	*/
        protected override decimal ComputeNextValue(IReadOnlyWindow<IndicatorDataPoint> window, IndicatorDataPoint input)
        {
            //if (window.Count < 3) return 0m;

            var xVals = new double[window.Count];
            var yVals = new double[window.Count];

            for (int i = 0; i < window.Count; i++)
            {
                xVals[i] = i;
                yVals[i] = (double) input.Value;
            }
            
            _xValues.Add(_dayCounter);
            _yValues.Add((double)input.Value);
 			_dayCounter = _yValues.Count() - 1;
 			//_dayCounter = _yValues.Count();
			//Console.WriteLine("[yCount]: " + _yValues.Count() + " [xCount]: " + _xValues.Count());
			
			if (_dayCounter < _days)
			{
				return 0;
			}
			else
			{
				var x1 = _xValues[_dayCounter-_days];
				var x2 = _xValues[_dayCounter];
				var y1 = _yValues[_dayCounter-_days];
				var y2 = _yValues[_dayCounter];
				decimal slope = (decimal)(y2 - y1) / (decimal)(x2 - x1);
				
				//Console.WriteLine("x1: " + x1 + ", y1: " + y1); 
				//Console.WriteLine("x2: " + x2 + ", y2: " + y2 + " slope: ", slope);
				
				//Console.WriteLine (String.Format(" x1: {0} y1 {1:0.000} x2 {2:0} y2 {3:0.000} Slope {4:0.000} ",
        		//									x1,y1,x2,y2,slope));
				return slope;
			}
        }
    }
}