Overall Statistics
Total Trades
1
Average Win
8.15%
Average Loss
0%
Compounding Annual Return
14.321%
Drawdown
9.500%
Expectancy
0
Net Profit
8.15%
Sharpe Ratio
1.224
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.136
Beta
0.015
Annual Standard Deviation
0.113
Annual Variance
0.013
Information Ratio
0
Tracking Error
0.158
Treynor Ratio
8.951
Total Fees
$2.00
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
    {
        public Stochastic stochastic;
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize()
        {
			
            //Start and End Date range for the backtest:
            SetStartDate(2014, 6, 1);         
            SetEndDate(2015, 1, 1); 
            
            //Cash allocation
            SetCash(25000);
            
            //Add as many securities as you like. All the data will be passed into the event handler:
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
            
            
            // create and register 15 minute stochastic indicator
            stochastic = new Stochastic("sto", 14, 3, 3);
            RegisterIndicator("SPY", stochastic, ResolveConsolidator("SPY", TimeSpan.FromMinutes(15)));
        }

        DateTime lastPlot;
        //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.HoldStock) 
            {
                SetHoldings("SPY", 0.5m);
            }
            
            if (Time - lastPlot >= TimeSpan.FromMinutes(15))
            {
                Plot("SPY", "stochd", stochastic.StochD.Current.Value);
                Plot("SPY", "stochk", stochastic.StochK.Current.Value);
                lastPlot = Time;
            }
        }
    }
}