Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
using System.Drawing; // for Color

namespace QuantConnect 
{ 
    public class ExampleStochasticChartingAlgorithm : QCAlgorithm
    {
        TradeBars prices = new TradeBars();
        
        Stochastic sto;
        
        String _symbol = "BUCY";
        String _plotter = "Stochastic";
        
        int overBought = 20;
        int overSold = 80;
        
        public override void Initialize()
        {
            SetStartDate(2010, 1, 1);
            SetEndDate(2011, 1, 1);
            
            int KPeriod = 14;
            int DPeriod = 3;

            AddSecurity(SecurityType.Equity, _symbol, Resolution.Daily); 
            
            //https://github.com/QuantConnect/Lean/blob/master/Algorithm/QCAlgorithm.Indicators.cs#L530
            sto = STO(_symbol,14,KPeriod,DPeriod);
            
            //Charting in https://github.com/QuantConnect/Lean/blob/master/Common/Charting.cs
            Chart plotter = new Chart(_plotter);
            plotter.AddSeries(new Series("D", SeriesType.Line, " ",Color.Red));
            plotter.AddSeries(new Series("K", SeriesType.Line, " ",Color.Blue));
            plotter.AddSeries(new Series("Over Bought", SeriesType.Line, " ",Color.Black));
            plotter.AddSeries(new Series("Over Sold", SeriesType.Line, " ",Color.Black));
            AddChart(plotter);
            
            Schedule.On(DateRules.EveryDay(), TimeRules.Every(TimeSpan.FromMinutes(10)), () =>
            {
                Log(string.Format("{0} {1}",sto.StochD,sto.StochK));
            }); 
        }
        
        public override void OnEndOfDay() 
        {
        	if (sto.IsReady)
        	{
        		Plot(_plotter,"D", sto.StochD);
        		Plot(_plotter,"K", sto.StochK);
        		Plot(_plotter,"Over Bought", overBought);
        		Plot(_plotter,"Over Sold", overSold);
        	}
        }
    }
    
}