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 |
namespace QuantConnect.Algorithm.CSharp { /// <summary> /// This is a test to understand indicator data and rolling windows. /// </summary> public class IndicatorTest : QCAlgorithm { private Symbol symbolOanda = QuantConnect.Symbol.Create("EURUSD", SecurityType.Forex, Market.Oanda); private Symbol symbolFXCM = QuantConnect.Symbol.Create("EURUSD", SecurityType.Forex, Market.FXCM); private Resolution resolution = Resolution.Daily; private RollingWindow<IndicatorDataPoint> macdOandaWindow; private RollingWindow<IndicatorDataPoint> macdFXCMWindow; private MovingAverageConvergenceDivergence macdOanda; private MovingAverageConvergenceDivergence macdFXCM; public override void Initialize() { SetStartDate(2018, 12, 03); //Set Start Date SetEndDate(2018, 12, 10); //Set End Date AddForex(symbolOanda, resolution); AddForex(symbolFXCM, resolution); macdOanda = MACD( symbolOanda, 12, 26, 1, MovingAverageType.Exponential, resolution ); macdOanda.Updated += (sender, updated) => macdOandaWindow.Add(updated); macdOandaWindow = new RollingWindow<IndicatorDataPoint>(4); macdFXCM = MACD( symbolFXCM, 12, 26, 1, MovingAverageType.Exponential, resolution ); macdFXCM.Updated += (sender, updated) => macdFXCMWindow.Add(updated); macdFXCMWindow = new RollingWindow<IndicatorDataPoint>(4); SetWarmUp(30); } public override void OnData(Slice data) { if (IsWarmingUp) return; if ( data.ContainsKey(symbolOanda)) Log("Oanda data.Time = " + data.Time.ToString() + ": macdOandaWindow[0].Time = " + macdOandaWindow[0].Time.ToString() + ", values = " + macdOandaWindow[0].Value.ToString("0.00000") + ", " + macdOandaWindow[1].Value.ToString("0.00000") + ", " + macdOandaWindow[2].Value.ToString("0.00000") + ", " + macdOandaWindow[3].Value.ToString("0.00000") ); if ( data.ContainsKey(symbolFXCM)) Log("FXCM data.Time = " + data.Time.ToString() + ": macdFXCMWindow[0].Time = " + macdFXCMWindow[0].Time.ToString() + ", values = " + macdFXCMWindow[0].Value.ToString("0.00000") + ", " + macdFXCMWindow[1].Value.ToString("0.00000") + ", " + macdFXCMWindow[2].Value.ToString("0.00000") + ", " + macdFXCMWindow[3].Value.ToString("0.00000") ); } } }