Overall Statistics
Total Trades
59
Average Win
0.03%
Average Loss
-0.01%
Compounding Annual Return
4039.256%
Drawdown
6.200%
Expectancy
0.321
Net Profit
3.107%
Sharpe Ratio
3.658
Loss Rate
55%
Win Rate
45%
Profit-Loss Ratio
1.95
Alpha
-3.325
Beta
-7.03
Annual Standard Deviation
0.561
Annual Variance
0.315
Information Ratio
4.622
Tracking Error
0.61
Treynor Ratio
-0.292
Total Fees
$0.00
namespace QuantConnect
{

    public class ChartBug : QCAlgorithm
    {

        private List<string> _currencyPairs = new List<string>()
        {
            "EURUSD",
            //"USDJPY",
            "GBPUSD",
            //"AUDUSD",
            //"USDCHF",
            //"NZDUSD",
            //"USDCAD"
        };

        private DateTime startDate = new DateTime(2016, 12, 28); //start date
        private DateTime endDate = new DateTime(2017, 1, 1); //end date
        private List<Chart> stockPlot = new List<Chart>();

        public override void Initialize()
        {
            //Setting start and end date
            SetStartDate(startDate);
            SetEndDate(endDate);

            //Setting my cash
            SetCash(100000);

            //Adding pairs at base resolution and 
            foreach (var pair in _currencyPairs)
            {
                AddForex(pair, Resolution.Hour);
                stockPlot.Add(new Chart(pair));
            }

            //AddData<DailyFx>("DFX", Resolution.Hour, DateTimeZone.Utc);


            //Setting up my charts

            //Series assetOpenPrice = new Series("Open", SeriesType.Scatter, 0);
            //Series assetClosePrice = new Series("Close", SeriesType.Scatter, 0);
            Series tradeinPrice = new Series("TradeIN", SeriesType.Scatter, 0);
            Series tradeoutPrice = new Series("TradeOUT", SeriesType.Scatter, 0);
            //Series tradeinCTLPrice = new Series("TradeINCTL", SeriesType.Scatter, 0);
            //Series tradeoutCTLPrice = new Series("TradeOUTCTL", SeriesType.Scatter, 0);
            Series fastMA = new Series("FastMA", SeriesType.Line, 0);
            Series slowMA = new Series("SlowMA", SeriesType.Line, 0);

            foreach (var chart in stockPlot)
            {
            //    chart.AddSeries(assetOpenPrice);
            //    chart.AddSeries(assetClosePrice);
                chart.AddSeries(tradeinPrice);
                chart.AddSeries(tradeoutPrice);
            //    chart.AddSeries(tradeinCTLPrice);
            //    chart.AddSeries(tradeoutCTLPrice);
                chart.AddSeries(fastMA);
                chart.AddSeries(slowMA);
                AddChart(chart);
            }
            

        }


        public override void OnData(Slice data)
        {
			var rnd = new Random();

            foreach (var bar in data.QuoteBars) //Iterate on the data
            {
                                if (bar.Value.Symbol.Value == "EURUSD")
                                {
                                    SetHoldings( bar.Value.Symbol.Value, 7);
                                    Plot(bar.Value.Symbol.Value, "TradeIN", bar.Value.Ask.Close);
                                    //Plot(currency.Key, "TradeINCTL", (decimal)(double)trade.Value["OpenedPrice"]);
                                }
                                else if (bar.Value.Symbol.Value == "GBPUSD")
                                {
                                    SetHoldings(bar.Value.Symbol.Value, -7);
                                    Plot(bar.Value.Symbol.Value, "TradeIN", bar.Value.Bid.Close);
                                    //Plot(currency.Key, "TradeINCTL", (decimal)(double)trade.Value["OpenedPrice"]);
                                }

                            if (rnd.Next(1,3) == 3)
                            {
                                    Liquidate(bar.Value.Symbol.Value);
                                    Plot(bar.Value.Symbol.Value, "TradeOUT", bar.Value.Bid.Close);
                                   // Plot(currency.Key, "TradeOUTCTL", (decimal)(double)trade.Value["ClosedPrice"]);
                                
                            }
            }
         
        }

    }
}