Overall Statistics
Total Trades
304
Average Win
0.26%
Average Loss
-0.26%
Compounding Annual Return
-0.425%
Drawdown
5.000%
Expectancy
-0.067
Net Profit
-2.664%
Sharpe Ratio
-0.22
Probabilistic Sharpe Ratio
0.032%
Loss Rate
53%
Win Rate
47%
Profit-Loss Ratio
1.00
Alpha
-0.003
Beta
-0.002
Annual Standard Deviation
0.015
Annual Variance
0
Information Ratio
-0.787
Tracking Error
0.164
Treynor Ratio
1.433
Total Fees
$0.00
Estimated Strategy Capacity
$24000000.00
namespace QuantConnect 
{ 
	/// <summary>
    /// QCU How do I create Custom Charts?
    /// 
    /// The entire charting system of quantconnect is adaptable. You can adjust it to draw whatever you'd like.
    /// 
    /// Charts can be stacked, or overlayed on each other.
    /// Series can be candles, lines or scatter plots.
    /// 
    /// Even the default behaviours of QuantConnect can be overridden
    /// 
    /// </summary>
    public class CustomChartingAlgorithm : QCAlgorithm
    {
        //Initializers:
        int dayCount = 0;
        bool tradedToday = false;
        SimpleMovingAverage _sma;
        RelativeStrengthIndex _rsi;
        TradeBars prices = new TradeBars();
        
        public override void Initialize()
        {
            SetStartDate(2013, 1, 1);
            SetStartDate(2015, 1, 1);

            AddSecurity(SecurityType.Forex, "EURUSD", resolution: Resolution.Minute);
            
            //#5 - Stock Plotter with Trades
            Chart plotter = new Chart("Plotter");
            plotter.AddSeries(new Series("EURUSD", SeriesType.Line, index:0));
            plotter.AddSeries(new Series("EURUSD-200MA", SeriesType.Line, index:0));
            plotter.AddSeries(new Series("Buy", SeriesType.Scatter, index:0));
            plotter.AddSeries(new Series("Sell", SeriesType.Scatter, index:0));
            plotter.AddSeries(new Series("EURUSD-RSI", SeriesType.Line, index:1));
            AddChart(plotter);
            
            _sma = SMA("EURUSD", 7, Resolution.Daily);
            _rsi = RSI("EURUSD", 7, MovingAverageType.Simple, Resolution.Daily);
        }
        
        /// <summary>
        /// New Trade Bar Event Handler
        /// </summary>
        public void OnData(Slice data)
        {
            
            //Every 7th day go long everything:
            if ( !Portfolio.Invested && (dayCount % 7 == 0) && !tradedToday )
            {
                SetHoldings( "EURUSD" , 0.25 );
                if (data.ContainsKey("EURUSD")) Plot("Plotter", "Buy", data["EURUSD"].Price);
                tradedToday = true;
            }
            
            //Every 13th day close out portfolio:
            if ( Portfolio.Invested && (dayCount % 13 == 0) && !tradedToday )
            {
                Liquidate();
                if (data.ContainsKey("EURUSD")) Plot("Plotter", "Sell", data["EURUSD"].Price);
                tradedToday = true;
            }
        }
        
        public override void OnEndOfDay() 
        {
                //Track # of Days:
                dayCount++;
                tradedToday = false;
                
                //#5 Manual Stock Plotter: Plot price once per day:
                if (Securities.ContainsKey("EURUSD") && _sma.IsReady && _rsi.IsReady) {
                	Plot("Plotter", "EURUSD", Securities["EURUSD"].Price);
                	Plot("Plotter", "EURUSD-200MA", _sma);
                	Plot("Plotter", "EURUSD-RSI", _rsi);
                }
        }
    }
    
}