Overall Statistics |
Total Trades 1 Average Win 0% Average Loss -5.42% Compounding Annual Return -12.674% Drawdown 7.600% Expectancy -1 Net Profit -5.424% Sharpe Ratio -1.576 Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.111 Beta 0.06 Annual Standard Deviation 0.067 Annual Variance 0.004 Information Ratio -1.75 Tracking Error 0.119 Treynor Ratio -1.749 Total Fees $4.00 |
using QuantConnect.Data.Consolidators; namespace QuantConnect { /* * QuantConnect University: FOREX - Using Currency Data * * QuantConnect allows you to use currency data for your backtest with a * simple line of code. See the SecurityType.Forex below. */ public class FOREXBasicTemplateAlgorithm : QCAlgorithm { BollingerBands _bb; //Use our new consolidator class - 15 minutes / 15 bars joined. decimal _price; public override void Initialize() { SetStartDate(2015, 1, 4); SetEndDate(DateTime.Now.Date.AddDays(-1)); SetCash(2000); AddSecurity(SecurityType.Forex, "EURUSD", Resolution.Minute); _bb = new BollingerBands(20, 1, MovingAverageType.Simple); var fifteenConsolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(15)); fifteenConsolidator.DataConsolidated += OnDataFifteen; SubscriptionManager.AddConsolidator("EURUSD",fifteenConsolidator); RegisterIndicator("EURUSD", _bb, fifteenConsolidator, x => x.Value); } public void OnData(TradeBars data) { if (!_bb.IsReady) return; TradeBar EURUSD = data["EURUSD"]; if (!Portfolio.HoldStock) { Order("EURUSD", 1000); Debug("Purchased EURUSD on " + Time.ToShortDateString()); } } private void OnDataFifteen(object sender,TradeBar consolidated) { _price = consolidated.Close; if (!_bb.IsReady) return; Plot("BB", "Price", _price); Plot("BB", _bb.UpperBand, _bb.MiddleBand, _bb.LowerBand); } // Fire plotting events once per day: public override void OnEndOfDay() { Log("EndOfDay"); } } }