Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 27.395% Drawdown 1.300% Expectancy 0 Net Profit 0% Sharpe Ratio 4.04 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.019 Beta 0.937 Annual Standard Deviation 0.058 Annual Variance 0.003 Information Ratio -3.275 Tracking Error 0.011 Treynor Ratio 0.252 Total Fees $2.23 |
namespace QuantConnect.Algorithm.CSharp { public class STO_RSI_DiffBars : QCAlgorithm { private Symbol _spy; private Stochastic _sto; private RelativeStrengthIndex _rsi; private RollingWindow<TradeBar> _win; public override void Initialize() { SetStartDate(2017, 01, 01); //Set Start Date AddEquity("SPY", Resolution.Minute); _spy = Securities["SPY"].Symbol; _rsi = new RelativeStrengthIndex(14); _sto = new Stochastic(12, 3, 5); _win = new RollingWindow<TradeBar>(2); var consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(15)); SubscriptionManager.AddConsolidator(_spy, consolidator); consolidator.DataConsolidated += OnConsolidatorData; } public void OnConsolidatorData(object s, TradeBar bar) { // Populate rolling window _win.Add(bar); if (!_win.IsReady) return; // Updates Stochastic with the previous bar _sto.Update(_win[1]); // Updates RSI with the current bar _rsi.Update(bar.EndTime, bar.Close); if(!_sto.IsReady || !_rsi.IsReady) return; Plot("Indicators", _sto); Plot("Indicators", _rsi); if(!Portfolio.Invested) { SetHoldings(_spy, 1); } } public void OnData(TradeBars data) { // } } }