Overall Statistics
Total Trades
1
Average Win
179.71%
Average Loss
0%
Compounding Annual Return
67.449%
Drawdown
38.300%
Expectancy
0
Net Profit
179.707%
Sharpe Ratio
1.241
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.427
Beta
1.469
Annual Standard Deviation
0.524
Annual Variance
0.275
Information Ratio
0.997
Tracking Error
0.5
Treynor Ratio
0.443
Total Fees
$9.01
namespace QuantConnect 
{   
    /*
    *   QuantConnect University: Full Basic Template:
    *
    *   The underlying QCAlgorithm class is full of helper methods which enable you to use QuantConnect.
    *   We have explained some of these here, but the full algorithm can be found at:
    *   https://github.com/QuantConnect/QCAlgorithm/blob/master/QuantConnect.Algorithm/QCAlgorithm.cs
    */
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
        TradeBar _tslaDaily;
        string symbol = "TSLA";
        RelativeStrengthIndex rsis;
        RelativeStrengthIndex rsiw;
        RelativeStrengthIndex rsie;
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize()
        {
            //Start and End Date range for the backtest:
            SetStartDate(2013, 5, 23);
            SetEndDate(DateTime.Now.Date.AddDays(-1));
            
            
            //Cash allocation
            SetCash(75000);
            //Add as many securities as you like. All the data will be passed into the event handler:
            AddSecurity(SecurityType.Equity, symbol, Resolution.Minute);
            Securities[symbol].SetDataNormalizationMode(DataNormalizationMode.Raw);
            
            rsiw = RSI(symbol, 14, MovingAverageType.Wilders, Resolution.Daily);
            rsis = RSI(symbol, 14, MovingAverageType.Simple, Resolution.Daily);
            rsie = RSI(symbol, 14, MovingAverageType.Exponential, Resolution.Daily);
            
            var dailyConsolidator = new TradeBarConsolidator(TimeSpan.FromDays(1));
            dailyConsolidator.DataConsolidated += OnDataDaily;
            SubscriptionManager.AddConsolidator("TSLA",dailyConsolidator);
        }
        private void OnDataDaily(object sender,TradeBar consolidated)
        {
            
            if (Time.Year < 2015) return;
            _tslaDaily = consolidated;
            
           Log(string.Format("S:{0}|W:{1}|E:{2}", 
                rsis.Current.Value.ToString("0.00"), 
                rsiw.Current.Value.ToString("0.00"), 
                rsie.Current.Value.ToString("0.00"))
                );
        }

        //Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
        public void OnData(TradeBars data) 
        {
            if (!Portfolio.Invested)
            {
                SetHoldings(symbol, 0.5m);
            }
        }
    }
}