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; namespace QuantConnect.Algorithm.CSharp { public class BasicTemplateAlgorithm : QCAlgorithm { public override void Initialize() { SetStartDate(2018, 9, 17); //Set Start Date SetEndDate(DateTime.Now); //Set End Date SetCash(100000); //Set Strategy Cash AddForex("GBPAUD", Resolution.Minute); var myConsolidator = new CustomConsolidator(); myConsolidator.DataConsolidated += OnDataConsolidated; SubscriptionManager.AddConsolidator("GBPAUD", myConsolidator); foreach (var data in History<QuoteBar>("GBPAUD", TimeSpan.FromDays(7))) { myConsolidator.Update(data); } var chart = new Chart("Plot"); var series = new Series("GBPAUD", SeriesType.Line, "Close", Color.Red); chart.AddSeries(series); } public void OnDataConsolidated(object sender, QuoteBar consolidated) { if (consolidated != null) Plot("Plot", "GBPAUD", consolidated.Value); } public override void OnData(Slice data) { } } public class CustomConsolidator : QuoteBarConsolidator { private QuoteBar _consolidatedBar; private static Int32 integ; private TimeSpan endOfDay; public CustomConsolidator() : base(integ) { _consolidatedBar = new QuoteBar(); endOfDay = new TimeSpan(16, 59, 0); } public override Type OutputType { get { return typeof (QuoteBar); } } public override void Update(QuoteBar data) { if (data == null) return; if (data != null) { var now = data.Time.TimeOfDay; if (now == endOfDay) { OnDataConsolidated(_consolidatedBar); _consolidatedBar = new QuoteBar { Time = data.Time, Symbol = data.Symbol }; } else { _consolidatedBar.Update(data.Close, data.Bid.Close, data.Ask.Close, 0, data.LastBidSize, data.LastAskSize); } } } } }