Overall Statistics
Total Trades
202
Average Win
0.33%
Average Loss
-0.35%
Compounding Annual Return
1.521%
Drawdown
3.000%
Expectancy
0.085
Net Profit
3.269%
Sharpe Ratio
0.383
Loss Rate
44%
Win Rate
56%
Profit-Loss Ratio
0.94
Alpha
0.003
Beta
0.162
Annual Standard Deviation
0.029
Annual Variance
0.001
Information Ratio
-0.391
Tracking Error
0.101
Treynor Ratio
0.068
Total Fees
$303.00
using System.Drawing;

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, "", Color.Green, ScatterMarkerSymbol.Triangle));
            plotter.AddSeries(new Series("Sell", SeriesType.Scatter, "", Color.Red, ScatterMarkerSymbol.TriangleDown));
            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(TradeBars data)
        {
            try 
            {
                //Save price data:
                foreach (string symbol in data.Keys)
                {
                    if (!prices.ContainsKey(symbol))
                    {
                        prices.Add(symbol, data[symbol]);
                    } else {
                        prices[symbol] = data[symbol];
                    }
                }
                
                //Every 7th day go long everything:
                if ( !Portfolio.Invested && (dayCount % 7 == 0) && !tradedToday )
                {
                    SetHoldings( "SPY" , 0.25 );
                    SetHoldings( "EURUSD" , 0.25 );
                    if (prices.ContainsKey("EURUSD")) Plot("Plotter", "Buy", prices["EURUSD"].Price);
                    tradedToday = true;
                }
                
                //Every 13th day close out portfolio:
                if ( Portfolio.Invested && (dayCount % 13 == 0) && !tradedToday )
                {
                    Liquidate();
                    if (prices.ContainsKey("EURUSD")) Plot("Plotter", "Sell", prices["EURUSD"].Price);
                    tradedToday = true;
                }
            } 
            catch (Exception err) 
            {
                Error("OnData Err: " + err.Message);    
            }
        }
        
        public override void OnEndOfDay() 
        {
            try 
            {
                //Track # of Days:
                dayCount++;
                tradedToday = false;
                
                //#5 Manual Stock Plotter: Plot price once per day:
                if (prices.ContainsKey("EURUSD") && _sma.IsReady && _rsi.IsReady) {
                	Plot("Plotter", "EURUSD", prices["EURUSD"].Price);
                	Plot("Plotter", "EURUSD-200MA", _sma);
                	Plot("Plotter", "EURUSD-RSI", _rsi);
                }
            } 
            catch (Exception err) 
            {
                Error("OnEndOfDay Err:" + err.Message);
            }
        }
    }
    
}