Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 24.438% Drawdown 1.800% Expectancy 0 Net Profit 0% Sharpe Ratio 3.068 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.044 Beta 1.008 Annual Standard Deviation 0.073 Annual Variance 0.005 Information Ratio -3.332 Tracking Error 0.013 Treynor Ratio 0.222 Total Fees $1.14 |
namespace QuantConnect { public class IndicatorConsolidator : QCAlgorithm { AverageTrueRange _atr; SimpleMovingAverage _sma; public override void Initialize() { SetStartDate(2016, 12, 1); SetEndDate(DateTime.Now.Date.AddDays(-1)); SetCash(50000); var symbol = "SPY"; AddSecurity(SecurityType.Equity, symbol, Resolution.Minute); var fiveMinuteConsolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(5)); _atr = new AverageTrueRange("ATR_" + symbol, 5, MovingAverageType.Simple); _sma = new SimpleMovingAverage("SMA_" + symbol, 5); RegisterIndicator(symbol, _atr, fiveMinuteConsolidator); RegisterIndicator(symbol, _sma, fiveMinuteConsolidator); SubscriptionManager.AddConsolidator(symbol, fiveMinuteConsolidator); fiveMinuteConsolidator.DataConsolidated += FiveMinuteHandler; } private void FiveMinuteHandler(object sender, TradeBar bar) { Debug(Time + " -> "+ _sma); if (!Portfolio.Invested && _sma > bar.Close) { SetHoldings("SPY", 1); } } public void OnData(TradeBars data) { // } } }